A DSA Cheat Sheet I Actually Use
A compact set of notes on arrays, trees, graphs, dynamic programming, and the patterns that come up over and over again.
Article Content
# A DSA Cheat Sheet I Actually Use
These are the notes I find myself coming back to when I want a quick reset before practice or interviews.
Arrays and Strings
- Two pointers: great for sorted arrays, reverse scans, and pair problems.
- Sliding window: use it when the question involves a contiguous range, substring, or subarray.
- Prefix sums: useful when repeated range queries would otherwise be too slow.
Linked Lists
- Fast and slow pointers: cycle detection, middle node, and split problems.
- Dummy heads: they make insert/delete edge cases much cleaner.
- Always draw the pointer updates before coding if the list logic feels messy.
Trees and Graphs
- DFS for structure, recursion, and "explore everything" problems.
- BFS for shortest paths on unweighted graphs and level-order traversal.
- Keep a visited set unless you are absolutely sure the structure is acyclic.
Heaps and Priority Queues
- Use a min-heap when you need the next smallest item repeatedly.
- Use a max-heap for top-k style problems.
- If you keep sorting the same thing over and over, a heap might be the better tool.
Dynamic Programming
- Define the state clearly.
- Write the transition.
- Figure out the base case.
- Then decide whether memoization or tabulation feels more natural.
My interview reminder list
- Clarify the input and constraints.
- Talk through brute force first.
- Name the pattern before you code.
- Watch time and space complexity.
- Test edge cases: empty input, one element, duplicates, negative values, overflow, and off-by-one mistakes.
That checklist has saved me more than once.