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.

  1. Problem: MaxQueue
  2. Solution: Scanning for the Maximum
  3. Solution: Copying MinStack
  4. Solution: Keeping the Candidates
  5. Solution: Two Deques
  6. Solution: Tracing MaxQueue
  7. Solution: Cost
  8. Solution: Two MaxStacks
  9. Problem: Sliding Window Maximum
  10. Solution: Scanning Every Window
  11. Solution: A Running Maximum
  12. Solution: Keeping the Candidates
  13. Solution: Storing Positions, Not Values
  14. Solution: A Deque of Indices
  15. Solution: Tracing the Deque
  16. Solution: Edge Cases and Cost