Timeline for Class that implements a queue using two stacks
Current License: CC BY-SA 3.0
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 14, 2016 at 1:29 | comment | added | mdfst13 |
While it may be true that two stacks is a dumb way to implement a queue unless all you have is Turing machines, this is incorrect. If I copy and paste the OP's code into a file and fix the imports, then copy and paste your code, then add System.out.println calls around each q.remove call, I get a b c -- which is correct. Not a c b as you write. Perhaps you were confused by the shiftStacks name? It's gated, so it doesn't always shift.
|
|
Jun 23, 2014 at 5:03 | vote | accept | CommunityBot | ||
Jun 19, 2014 at 23:02 | history | answered | rolfl | CC BY-SA 3.0 |