CJCoding With Joseph
15free / daySign inCreate account

Build a Queue from a Vector

Write a function queue<int> toQueue(const vector<int>& v) that returns a new queue<int> containing the elements of v in the same order, so v[0] ends up at the front of the queue.

The first test builds a queue from {4, 8, 15}, drains it and prints the values separated by spaces (see Expected Output).

The second test passes an empty vector and prints the size of the returned queue:
Size: 0

Do NOT write a main function.

Expected Output:

4 8 15
Size: 0

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
STL ContainersQueues
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.