- Published on
- Sat Feb 26, 2022

# Leetcode with composable patterns

Leetcode grinding is a sad part of life as a software engineer. Especially as one gains experience it is really hard and a ridiculous time sink to go back to leetcode during every interview season. There are 100s of problems in Leetcode for each area. DFS alone has about 100 problems (lot more now). The typical way a candidate solves a leetcode problem is to think of the raw mechanics as well as the problem specific detail in the same train of thought. For example a problem that needs DFS requires the candidate to think about how to implement DFS, as well as what to do at different points in time (eg when a node is entered, exited, edge visited etc).

The goal of this set of guides is to see how to solve leetcode problems using patterns. Algorithmic patterns are explained *really* well in Skienna’s The Algorithm Design Manual. These patterns will be explained as different LC problems are handled. This has two clear advantages:

- Seperate the foundational templates (eg DFS, BFS etc) from problem specific details via “hooks”
- We only have to memorize one foundational template per algorithm so that the next time a candidate arrives at the problem, there is a lot less to think about instead of having to remmeber how to implement every variation of DFS to suit the problem.
- Opportunity to demonstrate higher level thinking in abstractions.

Watch out for this series.