You are viewing a single comment's thread. Return to all comments →
Guys the point of this is to not rely too much on built-ins, so using collections.deque would likely not work in an interview.
That being said using stacks for this in Python seems to be too slow so the answer is don't implement Queues with two stacks in Python ;)
They ask you sometimes how to do a swap without a temp number. It helps them to see how creative you are.
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Queue using Two Stacks
You are viewing a single comment's thread. Return to all comments →
Guys the point of this is to not rely too much on built-ins, so using collections.deque would likely not work in an interview.
That being said using stacks for this in Python seems to be too slow so the answer is don't implement Queues with two stacks in Python ;)
They ask you sometimes how to do a swap without a temp number. It helps them to see how creative you are.