8 Ad Hoc Problems and Advanced Techniques

This chapter covers
- Approaching problems that do not fall into any of the previous categories.
- Solving problems using the forward-backward technique.
- Applying the coordinate compression principle to reduce time and space complexities.
- Using and manipulating tree structures.
- Simplifying programs using dictionaries and maps.
Ad hoc problems, also called logic problems or general problems, are problems that do not fall into any of the categories already discussed: modeling, searching, or geometry. Although there’s no single approach that will always work to solve these problems, there are a handful of techniques that can help you solve many of these problems, or at least simplify them.