E Piss Bed
EPSBD is a mnemonic I use to remember five helpful approaches to solving algorithmic problems that I got from Cracking the Coding Interview by Gayle McDowell:
- Examplify: Derive rules from examples. To compute the angle between the hour and minute hands in a clock, first derive the rules for computing the angle of each hand separately, then derive the rule for computing the angle between the hands in terms of them.
- Pattern match: Adapt the solution to a similar problem. To find the smallest element in a sorted array that’s been rotated, you just need to find the discontinuity where the element order changes, so use binary search to find it.
- Simplify and generalize: Change a constraint to simplify the solution, then generalize it.
- Base case and build: Solve the base cases first, then the cases that build on those.
- Data structure brainstorm: In a process of elimination, apply data structures to a problem to find a fit. Applying lateral thinking and praying for luck also fall under this approach.