Sefism DSA and Problem Solving Cheat Sheet
A quick-revision companion to the DSA roadmap in nine chapters: complexity, arrays and hashing, linked lists, stacks and queues, recursion, sorting and searching, trees and heaps, graphs, coding patterns, dynamic programming and timed practice habits. Costs are stated for every structure and algorithm, in Python, Java, C++ or JavaScript editions. Use it after each roadmap stage and before a contest or coding round.
9
Sefism · Oct 2026
76 to 77
Sefism · Oct 2026
4 (Python, Java, C++, JavaScript)
Sefism · Oct 2026
2
Sefism · Oct 2026
Cheat sheet
Other
Sefism
Reference
Intermediate
Free
What this cheat sheet is
The DSA and problem solving cheat sheet is a quick-revision companion to the DSA and problem solving roadmap. It covers complexity, the core data structures, recursion and searching, trees, graphs, coding patterns, dynamic programming and timed practice, and states the cost of every structure and algorithm it mentions.
It is not a course. Each concept is a short entry: what it is, why it matters, and where it helps, an example or the classic mistake to avoid. Skim a chapter before a project, an exam or a coding round, and follow its links when a concept needs more depth.
Editions
The sheet comes in four language editions, matching the roadmap: Python, Java, C++ and JavaScript. The structure is the same in each, and the language-specific entries change. The arrays chapter has a concept on your language's built-in collections (list, dict, deque and heapq in Python; ArrayList, HashMap, ArrayDeque and PriorityQueue in Java; vector, unordered_map, map and priority_queue in C++; arrays, Map and Set in JavaScript), and the JavaScript edition adds a hand-written heap, since the language has none built in. Each edition holds about 76 concepts across nine chapters.
Chapter by chapter
- Complexity and Big-O (7 concepts). Big-O notation, the common growth rates, counting operations in loops, best, worst and average case, space complexity and the call stack, amortised cost, and reading constraints to guess the complexity a solution needs.
- Arrays, strings and hashing. Arrays and dynamic arrays, strings, hash maps and sets, composite and custom keys, prefix sums, integer limits and overflow, and your language's built-in collections.
- Linked lists, stacks and queues (7 concepts). Singly and doubly linked lists, the dummy head node, stacks, queues, deques and the monotonic stack.
- Recursion, sorting and searching (10 concepts). Recursion and the base case, recursion versus iteration, divide and conquer, merge sort, quicksort, counting sort, sorting with the standard library, binary search, lower and upper bound, and binary search on the answer.
- Trees and heaps. Binary trees and traversals, tree DFS and what a child returns, level order traversal, binary search trees, balanced search trees, and heaps and priority queues.
- Graphs (9 concepts). Graph representations, grids as graphs, BFS, DFS, union-find, cycle detection, topological sort, Dijkstra's shortest paths and minimum spanning trees.
- Coding patterns (10 concepts). Two pointers, sliding window, fast and slow pointers, merge intervals, top K elements, K-way merge, spotting graph problems, backtracking, tries and bitwise XOR tricks.
- Dynamic programming (10 concepts). State and transition, memoisation, tabulation, space optimisation, 0/1 and unbounded knapsack, longest common subsequence, grid paths and counting, and Kadane's algorithm.
- Timed practice and problem-solving habits (8 concepts). A 45-minute problem routine, clarifying the problem, brute force first, edge cases, testing by hand, thinking aloud, reviewing and re-solving misses, and contests and mixed problem lists.
Tips the sheet keeps coming back to
The sheet ends with short rules of thumb. A few of them:
- Read the constraints before designing anything: they tell you the complexity the solution needs.
- Write the brute force and its cost first, because the optimisation usually removes one of its loops.
- Sorted input suggests binary search or two pointers; a contiguous range suggests a sliding window or prefix sums.
- Fewest steps in an unweighted graph means BFS; non-negative weighted costs mean Dijkstra.
- For DP, define the state in one sentence, write the recursion, add a cache, and only then build a table.
Each edition adds its own, such as using long for large sums in Java or always passing a comparator to sort in JavaScript.
How to use it with the roadmap
- After each stage, read the matching chapter and check you can explain every concept in your own words. If one will not come, go back to that roadmap topic.
- Before a contest or coding round, read chapter 7 (patterns) and chapter 9 (habits). They are the two you will lean on under a clock.
- While solving, use it to check a cost you half remember, rather than searching the web and losing twenty minutes.
How it works on Sefism
Everything on Sefism is free to learn from. The public page at DSA and problem solving cheat sheet shows every chapter title, with the first two chapters open in full. Later chapters show their title, a short introduction and how many concepts they hold.
Keeping the sheet uses credits, and it is yours for good after that. Adding the DSA and problem solving roadmap to your dashboard also opens this sheet, so if you plan to follow the roadmap you do not need to keep the sheet separately. New members get starting credits when they join, and the first roadmap is free. Create a free account to get started, and if a concept still does not make sense after reading it, ask Tauseef a question.
Related on Sefism
- Is DSA still worth learning with AI?
- How to start DSA when you cannot solve problems
- Fifteen problem shapes and the move that solves each
- VisuAlgo, for stepping through a structure with your own input
- The Competitive programming cheat sheet, when you move on to contests
Frequently asked questions
Is a cheat sheet enough to learn DSA? No. It is for revising what you have already practised. The roadmap is where the learning and the problems are.
Which edition should I pick? The language you solve problems in. The concepts are the same; the collections, syntax notes and tips change.
What is the fastest chapter to revise before a coding round? Coding patterns, then timed practice habits. Most problems are recognised by their pattern, and most rounds are lost on habits rather than knowledge.
Ready to start?
Opens on Sefism in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.