4 ms·
Worst part is their max-stack isn't optimal. You can do it with O(1) additional space.
by bpicolo 13y ago
Worst part is their max-stack isn't optimal. You can do it with O(1) additional space.
- gameguy43 13y agoHm. How?
- BHSPitMonkey 13y agoPlease explain. Without maintaining that ordering, you're going to have to iterate over the entire stack after every pop, no? One of their requirements was to keep pop() at O(1) rather than O(n).