Skip to main content

All Questions

3 votes
4 answers
2k views

Iterating through stacks and queues?

Are stacks and queues allowed to be iterated over, conceptually? It “feels wrong” for some reason but I can't come up with a reason why it would be bad to see through the whole thing that's stacked/...
Lazar Ljubenović's user avatar
3 votes
1 answer
922 views

Why doesn't greedy approach work for following problem but the solution provided in the editorial does?

Problem Statement: Alexa has two stacks of non—negative integers, stack A = [a0,a1, . . . ,an_1] and stack B = [b0, b1, . . . ,bm_1] where index 0 denotes the top of the stack. Alexa challenges Nick ...
Sourabh Khandelwal's user avatar
14 votes
2 answers
6k views

Amortized Analysis? (Worst-case Performance Guarantees)

What is Amortized Analysis? And how can it help me achieve worst-case performance guarantees in my programs? I was reading that the following techniques can help the programmer achieve Worst-case ...
Anthony's user avatar
  • 900