Trace [73, 74, 75, 71, 69, 72, 76, 73].
Day 0 (73): push 0. Stack: [0].
Day 1 (74): 74 > 73, pop 0, answer[0] = 1. Push 1. Stack: [1].
Day 2 (75): 75 > 74, pop 1, answer[1] = 1. Push 2. Stack: [2].
Day 3 (71): 71 < 75, push 3. Stack: [2, 3].
Day 4 (69): 69 < 71, push 4. Stack: [2, 3, 4].
Day 5 (72): 72 > 69, pop 4, answer[4] = 1. 72 > 71, pop 3, answer[3] = 2. Push 5. Stack: [2, 5].
Day 6 (76): 76 > 72, pop 5, answer[5] = 1. 76 > 75, pop 2, answer[2] = 4. Push 6. Stack: [6].
Day 7 (73): 73 < 76, push 7. Stack: [6, 7].
Days 6 and 7 stay 0.
Each index pushed once, popped at most once. time. Stack and result array: space.