Stack to Vector Bottom First
mediumQuestion 519Write a function vector<int> bottomFirst(stack<int> s) that returns the stack's contents as a vector ordered from the bottom of the stack to the top.
Example: for a stack where 1, 2, 3 were pushed in that order (3 on top) the result is {1, 2, 3}, and the test prints the values separated by single spaces (see Expected Output).
For an empty stack return an empty vector; the test then prints the line empty.
Do NOT write a main function.
Expected output
1 2 3 empty
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
STL ContainersStacks
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.