Queue using Two Stacks

  • + 0 comments

    C++ Using a second stack to reverse the stack for poping/displaying first element just gives TLE for many testcases. Seems like problem design issue, editorial explain same logic also.

    Otherwise a vector is obviously faster to at least display the first element, but that wasnt the task I guess. (Ofc pop_front is still o(n))