A collection of my solutions to LeetCode problems, organised by common patterns/techniques and prioritised by topics that appear most frequently in technical interviews.
Source: algo.monster/problems/stats
Recognising patterns
IF INPUT ARRAY IS SORTED THEN
- Binary search
- Two pointers
IF ASKED FOR ALL PERMUTATIONS/SUBSETS THEN
- Backtracking
IF GIVEN A TREE THEN
- DFS
- BFS
IF GIVEN A GRAPH THEN
- DFS
- BFS
IF GIVEN A LINKED LIST THEN
- Two pointers
IF RECURSION IS BANNED THEN
- Stack
IF MUST SOLVE IN-PLACE THEN
- Swap corresponding values
- Store one or more different values in the same pointer
IF ASKED FOR MAXIMUM/MINIMUM SUBARRAY/SUBSET/OPTIONS THEN
- Dynamic programming
IF ASKED FOR TOP/LEAST K ITEMS THEN
- Heap
- QuickSelect
IF ASKED FOR COMMON STRINGS THEN
- Map
- Trie
ELSE
- Map/Set for O(1) time & O(n) space
- Sort input for O(nlogn) time and O(1) space
Leetcode articles
-
TOPICS WHICH YOU CAN'T SKIP [INTERVIEW PREPARATION | STUDY PLAN] USING LEETCODE
-
[Python] Powerful Ultimate Binary Search Template (solved many problems)
-
A comprehensive guide and template for monotonic stack based problems
-
Master HEAP: Understanding 4 patterns where HEAP data structure is used
-
Iterative | Recursive | DFS & BFS Tree Traversal | In, Pre, Post & LevelOrder | Views
-
All Types of Patterns for Bits Manipulations and How to use it