Top DSA coding patterns | Leetcode questions
- Sliding Window
- https://leetcode.com/problems/longest-substring-without-repeating-characters/
- https://leetcode.com/problems/sliding-window-maximum/
- https://leetcode.com/problems/minimum-window-subsequence/
- https://leetcode.com/problems/repeated-dna-sequences/
- https://leetcode.com/problems/minimum-window-substring/
- https://leetcode.com/problems/minimum-size-subarray-sum/
- https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
- https://leetcode.com/problems/find-all-anagrams-in-a-string/
2. Hash Maps
- https://leetcode.com/problems/design-hashmap/
- https://leetcode.com/problems/fraction-to-recurring-decimal/
- https://leetcode.com/problems/logger-rate-limiter/
- https://leetcode.com/problems/next-greater-element-i/
- https://leetcode.com/problems/isomorphic-strings/
- https://leetcode.com/problems/longest-palindrome/
- https://leetcode.com/problems/design-tic-tac-toe/
- https://leetcode.com/problems/contains-duplicate/
- https://leetcode.com/problems/two-sum/
3. Two Pointers
- https://leetcode.com/problems/valid-palindrome/
- https://leetcode.com/problems/3sum/
- https://leetcode.com/problems/reverse-words-in-a-string/
- https://leetcode.com/problems/valid-palindrome-ii/
- https://leetcode.com/problems/sort-list/ ( Linked List + Two pointers)
- https://leetcode.com/problems/container-with-most-water/
- https://leetcode.com/problems/linked-list-cycle-ii/ ( Linked List + Two pointers)
4 . Fast & Slow Pointers
- https://leetcode.com/problems/linked-list-cycle/
- https://leetcode.com/problems/happy-number/
- https://leetcode.com/problems/circular-array-loop/
- https://leetcode.com/problems/middle-of-the-linked-list/
- https://leetcode.com/problems/palindrome-linked-list/
5. Merge Intervals
- https://leetcode.com/problems/merge-intervals/
- https://leetcode.com/problems/insert-interval/
- https://leetcode.com/problems/interval-list-intersections/
- https://leetcode.com/problems/employee-free-time/
- https://leetcode.com/problems/meeting-rooms-ii/
6. Cyclic Sort
- https://leetcode.com/problems/missing-number/
- https://leetcode.com/problems/first-missing-positive/
- https://leetcode.com/problems/find-the-duplicate-number/
- https://www.geeksforgeeks.org/find-a-repeating-and-a-missing-number/
- https://www.geeksforgeeks.org/find-first-k-natural-numbers-missing-given-array/
7. In-place Reversal of a LinkedList
- https://leetcode.com/problems/reverse-linked-list/
- https://leetcode.com/problems/reverse-nodes-in-k-group/
- https://leetcode.com/problems/reverse-linked-list-ii/
- https://leetcode.com/problems/reorder-list/
- https://leetcode.com/problems/swapping-nodes-in-a-linked-list/
- https://leetcode.com/problems/reverse-nodes-in-even-length-groups/
- https://leetcode.com/problems/swap-nodes-in-pairs/
8. Graph Breadth-First Search
- https://leetcode.com/problems/pacific-atlantic-water-flow/ ( BFS/DFS)
- https://leetcode.com/problems/rotting-oranges/
- https://leetcode.com/problems/longest-increasing-path-in-a-matrix/ ( BFS/DFS + topological sort)
9. Graph Depth First Search
- https://leetcode.com/problems/shortest-bridge/ (DFS/BFS)
- https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/ ( DFS/BFS/Union find)
- https://leetcode.com/problems/sum-of-distances-in-tree/ (DFS+ DP)
- https://leetcode.com/problems/reconstruct-itinerary/
- https://leetcode.com/problems/possible-bipartition/
- https://leetcode.com/problems/all-paths-from-source-to-target/ ( DFS+ Backtracking)
10. Heaps
- https://leetcode.com/problems/ipo/
- https://leetcode.com/problems/sliding-window-median/
- https://leetcode.com/problems/find-median-from-data-stream/
- https://leetcode.com/problems/task-scheduler/
- https://leetcode.com/problems/top-k-frequent-words/
11. Subsets
- https://leetcode.com/problems/subsets/
- https://leetcode.com/problems/permutations/
- https://leetcode.com/problems/letter-combinations-of-a-phone-number/
- https://leetcode.com/problems/generate-parentheses/
- https://leetcode.com/problems/partition-to-k-equal-sum-subsets/
12. Modified Binary Search
- https://leetcode.com/problems/search-in-rotated-sorted-array/
- https://leetcode.com/problems/first-bad-version/
- https://leetcode.com/problems/random-pick-with-weight/
- https://leetcode.com/problems/find-k-closest-elements/
- https://leetcode.com/problems/single-element-in-a-sorted-array/
- https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
13. Bitwise Manipulation
- https://leetcode.com/problems/find-the-difference/
- https://leetcode.com/problems/complement-of-base-10-integer/
- https://leetcode.com/problems/flipping-an-image/
- https://leetcode.com/problems/single-number/
- https://leetcode.com/problems/single-number-ii/
- https://leetcode.com/problems/reverse-bits/
14. Top ‘K’ Elements
- https://leetcode.com/problems/kth-largest-element-in-a-stream/
- https://leetcode.com/problems/reorganize-string/
- https://leetcode.com/problems/k-closest-points-to-origin/
- https://leetcode.com/problems/top-k-frequent-elements/
- https://leetcode.com/problems/kth-largest-element-in-an-array/
- https://leetcode.com/problems/kth-smallest-element-in-a-bst/
15. K-way Merge
- https://leetcode.com/problems/merge-sorted-array/
- https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/
- https://leetcode.com/problems/find-k-pairs-with-smallest-sums/
- https://leetcode.com/problems/merge-k-sorted-lists/
- https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/
- https://leetcode.com/problems/median-of-two-sorted-arrays/
16. Tree Breadth-First Search
- https://leetcode.com/problems/binary-tree-level-order-traversal/
- https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
- https://leetcode.com/problems/populating-next-right-pointers-in-each-node/
- https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/
- https://leetcode.com/problems/populating-next-right-pointers-in-each-node/
17. Tree Depth First Search
- https://leetcode.com/problems/flatten-binary-tree-to-linked-list/
- https://leetcode.com/problems/diameter-of-binary-tree/
- https://leetcode.com/problems/serialize-and-deserialize-binary-tree/
- https://leetcode.com/problems/invert-binary-tree/
- https://leetcode.com/problems/binary-tree-maximum-path-sum/
- https://leetcode.com/problems/maximum-depth-of-binary-tree/
- https://leetcode.com/problems/subtree-of-another-tree/
- https://leetcode.com/problems/same-tree/
18. Trie
- https://leetcode.com/problems/implement-trie-prefix-tree/
- https://leetcode.com/problems/search-suggestions-system/
- https://leetcode.com/problems/replace-words/
- https://leetcode.com/problems/design-add-and-search-words-data-structure/
- https://leetcode.com/problems/word-search-ii/
- https://leetcode.com/problems/lexicographical-numbers/
19. Topological Sort
- https://www.pepcoding.com/resources/online-java-foundation/graphs/compilation-order-official/ojquestion
- https://leetcode.com/problems/alien-dictionary/
- https://leetcode.com/problems/course-schedule/
- https://leetcode.com/problems/course-schedule-ii/
- https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/
- https://leetcode.com/problems/loud-and-rich/
- https://leetcode.com/problems/alien-dictionary/
20. Backtracking
- https://leetcode.com/problems/n-queens/
- https://leetcode.com/problems/word-search/
- https://leetcode.com/problems/house-robber-iii/
- https://leetcode.com/problems/restore-ip-addresses/
- https://leetcode.com/problems/sudoku-solver/
- https://leetcode.com/problems/matchsticks-to-square/
- https://leetcode.com/problems/permutations-ii/description/
21. Stack
- https://leetcode.com/problems/basic-calculator/
- https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/
- https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/
- https://leetcode.com/problems/exclusive-time-of-functions/
- https://leetcode.com/problems/flatten-nested-list-iterator/
- https://leetcode.com/problems/valid-parentheses/
- https://leetcode.com/problems/maximum-frequency-stack/
- https://leetcode.com/problems/largest-rectangle-in-histogram/
- https://leetcode.com/problems/evaluate-reverse-polish-notation/
- https://leetcode.com/problems/asteroid-collision/
22. Queue
- https://leetcode.com/problems/first-unique-character-in-a-string/
- https://leetcode.com/problems/implement-queue-using-stacks/
- https://leetcode.com/problems/implement-stack-using-queues/
- https://leetcode.com/problems/sliding-window-maximum/
- https://leetcode.com/problems/stamping-the-sequence/
- https://leetcode.com/problems/jump-game-vi/
- https://leetcode.com/problems/design-hit-counter/
- https://leetcode.com/problems/design-snake-game/
- https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/
23. Greedy
- https://leetcode.com/problems/jump-game/
- https://leetcode.com/problems/boats-to-save-people/
- https://leetcode.com/problems/gas-station/
- https://leetcode.com/problems/two-city-scheduling/
- https://leetcode.com/problems/jump-game-ii/
- https://leetcode.com/problems/non-overlapping-intervals/ ( Greedy + Dp)
- https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/ ( Greedy + Dp)
- https://leetcode.com/problems/lemonade-change/
24. Dynamic Programming
- https://leetcode.com/problems/climbing-stairs/
- https://leetcode.com/problems/coin-change/
- https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem0945/1
- https://leetcode.com/problems/n-th-tribonacci-number/
- https://leetcode.com/problems/partition-equal-subset-sum/
- https://leetcode.com/problems/word-break-ii/
- https://leetcode.com/problems/minimum-number-of-refueling-stops/
- https://leetcode.com/problems/longest-increasing-subsequence/
- https://leetcode.com/problems/unique-paths/
- https://leetcode.com/problems/longest-palindromic-subsequence/
- https://leetcode.com/problems/house-robber/
25. Union Find
- https://leetcode.com/problems/redundant-connection/
- https://leetcode.com/problems/number-of-islands/ ( Union Find / BFS/DFS)
- https://leetcode.com/problems/last-day-where-you-can-still-cross/
- https://leetcode.com/problems/regions-cut-by-slashes/
- https://leetcode.com/problems/minimize-malware-spread/
- https://leetcode.com/problems/number-of-provinces/
- https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/
26. Custom Data structures
- https://leetcode.com/problems/lfu-cache/
- https://leetcode.com/problems/min-stack/
- https://leetcode.com/problems/insert-delete-getrandom-o1/
- https://leetcode.com/problems/lru-cache/
- https://leetcode.com/problems/time-based-key-value-store/
- https://leetcode.com/problems/snapshot-array/
- https://leetcode.com/problems/design-in-memory-file-system/
- https://leetcode.com/problems/design-file-system/
27. String
- https://leetcode.com/problems/palindrome-permutation/
- https://leetcode.com/problems/group-anagrams/
- https://leetcode.com/problems/first-unique-character-in-a-string/
- https://leetcode.com/problems/ransom-note/
28. Divide & Conquer
- https://leetcode.com/problems/maximum-subarray/
- https://leetcode.com/problems/number-of-1-bits/
- https://leetcode.com/problems/majority-element/
29. Binary Search
30. Sorting
- https://leetcode.com/problems/meeting-rooms/
- https://leetcode.com/problems/4sum/ ( Sorting + Two pointers)
31. Prefix sum
32. Djikstra Algorithm
- https://leetcode.com/problems/network-delay-time/ ( Djikstra/ Floyd / Bellman)
- https://leetcode.com/problems/cheapest-flights-within-k-stops/
- https://leetcode.com/problems/reachable-nodes-in-subdivided-graph/
- https://leetcode.com/problems/path-with-maximum-probability/
- https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/
- https://leetcode.com/problems/path-with-minimum-effort/ ( Djikstra/ Floyd / Bellman)
- https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node/
33. Floyd Warshall
- https://leetcode.com/problems/evaluate-division/ (Floyd/ Union Find)
- https://leetcode.com/problems/cheapest-flights-within-k-stops/
- https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/ ( Floyd/Djikstra)
- https://leetcode.com/problems/course-schedule-iv/
- https://leetcode.com/problems/number-of-ways-to-arrive-at-destination/
34. Bellman Ford
- https://leetcode.com/problems/cheapest-flights-within-k-stops/
- https://leetcode.com/problems/cat-and-mouse/
- https://leetcode.com/problems/get-watched-videos-by-your-friends/
Don’t forgot to follow me for more articles !! If u liked please clap
For reference coding questions under above categories:
1.) https://designgurus.org/course/grokking-the-coding-interview
2.) https://www.educative.io/courses/grokking-coding-interview-patterns-java
4.) https://www.geeksforgeeks.org/must-do-coding-questions-for-companies-like-amazon-microsoft-adobe/