Practice Overview
These problems take the ideas and techniques you learned in the chapter and apply them to new contexts. It is best to attempt these after reading the chapter and feeling confident with the material. For each problem, write your own solution before reading the provided one. Give yourself more time to work through the challenge.
You can download the accompanying code for these practice problems: starter and solution.
- Problem: MaxQueue
- Solution: Scanning for the Maximum
- Solution: Copying MinStack
- Solution: Keeping the Candidates
- Solution: Two Deques
- Solution: Tracing MaxQueue
- Solution: Cost
- Solution: Two MaxStacks
- Problem: Sliding Window Maximum
- Solution: Scanning Every Window
- Solution: A Running Maximum
- Solution: Keeping the Candidates
- Solution: Storing Positions, Not Values
- Solution: A Deque of Indices
- Solution: Tracing the Deque
- Solution: Edge Cases and Cost