DSA coding patterns by N singh :)

Neeru K Singh
5 min readJan 12, 2023

--

  1. Sliding Window

1.1) https://leetcode.com/problems/longest-substring-without-repeating-characters/

1.2) https://leetcode.com/problems/minimum-window-substring/

1.3 https://leetcode.com/problems/longest-repeating-character-replacement/

1.4) https://leetcode.com/problems/sliding-window-maximum/

1.5) https://leetcode.com/problems/maximum-length-of-repeated-subarray/

1.6 ) https://leetcode.com/problems/find-k-closest-elements/

1.7) https://leetcode.com/problems/contains-duplicate-ii/

1.8 ) https://leetcode.com/problems/longest-repeating-character-replacement/

1.9) https://leetcode.com/problems/subarrays-with-k-different-integers/

1.10)https://leetcode.com/problems/longest-duplicate-substring/

2. Hash maps

2.1)https://leetcode.com/problems/two-sum/

2.2) https://leetcode.com/problems/set-matrix-zeroes/

2.3) https://leetcode.com/problems/contains-duplicate/

2.4) https://leetcode.com/problems/integer-to-roman/

2.5) https://leetcode.com/problems/roman-to-integer/

2.6) https://leetcode.com/problems/substring-with-concatenation-of-all-words/

2.7) https://leetcode.com/problems/first-missing-positive/

3. Dp

3.1) https://leetcode.com/problems/longest-palindromic-substring/

3.2) https://leetcode.com/problems/jump-game/

3.3) https://leetcode.com/problems/unique-paths/

3.4) https://leetcode.com/problems/climbing-stairs/

3.5) https://leetcode.com/problems/decode-ways/

3.6) https://leetcode.com/problems/best-time-to-buy-and-sell-stock/

3.7)https://leetcode.com/problems/word-break/

3.8)https://leetcode.com/problems/maximum-product-subarray/

3.9) https://leetcode.com/problems/house-robber/

3.10) https://leetcode.com/problems/house-robber-ii/

3.11) https://leetcode.com/problems/longest-increasing-subsequence/

3.12)https://leetcode.com/problems/coin-change/

3.13)https://leetcode.com/problems/counting-bits/ ( + Bit manipulation )

3.14)https://leetcode.com/problems/non-overlapping-intervals/

3.15)https://leetcode.com/problems/palindromic-substrings/

3.16)https://leetcode.com/problems/word-break/

3.17) https://leetcode.com/problems/word-break-ii/

4. Two Pointers

4.1) https://leetcode.com/problems/container-with-most-water/

4.2) https://leetcode.com/problems/3sum/

4.3) https://leetcode.com/problems/valid-palindrome/

4.4) https://leetcode.com/problems/trapping-rain-water/

4.5) https://leetcode.com/problems/next-permutation/

4.6) https://leetcode.com/problems/reverse-words-in-a-string/

4.7) https://leetcode.com/problems/string-compression/

4.8) https://leetcode.com/problems/3sum-closest/

4.9) https://leetcode.com/problems/next-greater-element-iii/

5. Linked List

5.1 ) https://leetcode.com/problems/remove-nth-node-from-end-of-list/

5.2) https://leetcode.com/problems/lru-cache/

5.3) https://leetcode.com/problems/reverse-linked-list/

5.4) https://leetcode.com/problems/linked-list-cycle/

5.5) https://leetcode.com/problems/copy-list-with-random-pointer/

5.6) https://leetcode.com/problems/palindrome-linked-list/

5.7) https://leetcode.com/problems/add-two-numbers/

5.8) https://leetcode.com/problems/palindrome-linked-list/

5.9) https://leetcode.com/problems/merge-two-sorted-lists/

5.10) https://leetcode.com/problems/odd-even-linked-list/

5.11) https://leetcode.com/problems/delete-node-in-a-linked-list/

5.12) https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/

5.13) https://leetcode.com/problems/middle-of-the-linked-list/

5.14) https://leetcode.com/problems/flatten-binary-tree-to-linked-list/

5.15) https://leetcode.com/problems/reverse-nodes-in-k-group/

6. Stack

6.1) https://leetcode.com/problems/valid-parentheses/

6.2) https://leetcode.com/problems/implement-stack-using-queues/

6.3) https://leetcode.com/problems/reorder-list/ ( Stack + Two pointers)

6.4) https://leetcode.com/problems/max-stack/

6.5) https://leetcode.com/problems/decode-string/

6.6) https://leetcode.com/problems/design-browser-history/

6.7) https://leetcode.com/problems/reorder-list/

6.8) https://leetcode.com/problems/basic-calculator/

6.9) https://leetcode.com/problems/largest-rectangle-in-histogram/

6.10) https://leetcode.com/problems/sum-of-total-strength-of-wizards/

6.11) https://leetcode.com/problems/stamping-the-sequence/

7. Recursion

7.1) https://leetcode.com/problems/powx-n/

7.2) https://leetcode.com/problems/power-of-two/

7.3) https://leetcode.com/problems/regular-expression-matching/ (+dp)

7.5) https://leetcode.com/problems/wildcard-matching/ (+dp)

7.6) https://leetcode.com/problems/all-possible-full-binary-trees/ (+dp)

7.7) https://leetcode.com/problems/power-of-three/

7.8) https://leetcode.com/problems/different-ways-to-add-parentheses/ (+dp)

7.9) https://leetcode.com/problems/swap-nodes-in-pairs/

7.10) https://leetcode.com/problems/number-of-digit-one/

8. K-way Merge + Divide & conquer

8.1) https://leetcode.com/problems/merge-k-sorted-lists/

8.2) https://leetcode.com/problems/maximum-subarray/ ( Divide & Conquer + Dp)

8.3) https://leetcode.com/problems/reverse-bits/ (Divide & Conquer)

8.4) https://leetcode.com/problems/number-of-1-bits/

8.5) https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/

8.6) https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/

8.7) https://leetcode.com/problems/kth-largest-element-in-an-array/

8.8) https://leetcode.com/problems/top-k-frequent-elements/

9. Binary search

9.1) https://leetcode.com/problems/binary-search/

9.2) https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/

9.3) https://leetcode.com/problems/missing-number/

9.4) https://leetcode.com/problems/find-k-closest-elements/

9.5) https://leetcode.com/problems/median-of-two-sorted-arrays/

9.6) https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k/

9.7) https://leetcode.com/problems/design-hit-counter/

9.8) https://leetcode.com/problems/maximum-profit-in-job-scheduling/

9.9) https://leetcode.com/problems/maximum-length-of-repeated-subarray/

9.10) https://leetcode.com/problems/search-in-rotated-sorted-array/

9.11) https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/

9.12) https://leetcode.com/problems/longest-increasing-subsequence/

10. Backtracking

10.1)https://leetcode.com/problems/combination-sum/

10.2) https://leetcode.com/problems/word-search/

10.3) https://leetcode.com/problems/letter-combinations-of-a-phone-number/

10.4)https://leetcode.com/problems/valid-sudoku/

10.5) https://leetcode.com/problems/word-ladder/

10.6) https://leetcode.com/problems/word-ladder-ii/

10.7) https://leetcode.com/problems/verbal-arithmetic-puzzle/

10.8) https://leetcode.com/problems/generate-parentheses/

10.9) https://leetcode.com/problems/word-search/

10.10.) https://leetcode.com/problems/numbers-with-same-consecutive-differences/

10.11) https://leetcode.com/problems/word-break-ii/

10.12) https://leetcode.com/problems/sudoku-solver/

10.13) https://leetcode.com/problems/n-queens/

10.14) https://leetcode.com/problems/permutations/

10.15) https://leetcode.com/problems/remove-invalid-parentheses/

10.16) https://leetcode.com/problems/palindrome-partitioning/

11. Arrays

11.1) https://leetcode.com/problems/rotate-image/

11.2) https://leetcode.com/problems/spiral-matrix/

11.3) https://leetcode.com/problems/insert-interval/

11.4) https://leetcode.com/problems/product-of-array-except-self/ ( arrays+ prefix sum)

11.5) https://leetcode.com/problems/encode-and-decode-strings/ ( +String)

11.6) https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/

11.7) https://leetcode.com/problems/unique-number-of-occurrences/

11.8) https://leetcode.com/problems/analyze-user-website-visit-pattern/

11.9) https://leetcode.com/problems/maximum-subarray/

11.10) https://leetcode.com/problems/next-permutation/

12. Sorting

12.1) https://leetcode.com/problems/group-anagrams/( String+Sorting)

12.2) https://leetcode.com/problems/merge-intervals/

12.3) https://leetcode.com/problems/valid-anagram/

12.4) https://leetcode.com/problems/meeting-rooms/

12.5) https://leetcode.com/problems/meeting-rooms-ii/

12.6) https://leetcode.com/problems/group-anagrams/

12.7)https://leetcode.com/problems/orderly-queue/

12.8) https://leetcode.com/problems/reorder-data-in-log-files/

13. Tree

13.1) https://leetcode.com/problems/validate-binary-search-tree/

13.2) https://leetcode.com/problems/same-tree/

13.3) https://leetcode.com/problems/binary-tree-level-order-traversal/

13.4) https://leetcode.com/problems/maximum-depth-of-binary-tree/

13.5) https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/

13.5) https://leetcode.com/problems/binary-tree-maximum-path-sum/

13.6) https://leetcode.com/problems/invert-binary-tree/

13.7) https://leetcode.com/problems/kth-smallest-element-in-a-bst/

13.8) https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/

13.9) https://leetcode.com/problems/serialize-and-deserialize-binary-tree/

13.10) https://leetcode.com/problems/subtree-of-another-tree/

13.11)https://leetcode.com/problems/sum-of-distances-in-tree/

13.12) https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/

13.13) https://leetcode.com/problems/binary-tree-vertical-order-traversal/

13.14) https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/

13.15) https://leetcode.com/problems/binary-tree-pruning/

13.16) https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/

13.17) https://leetcode.com/problems/maximum-product-of-splitted-binary-tree/

13.18) https://leetcode.com/problems/find-leaves-of-binary-tree/

14. Graph Bfs+Dfs

14.1) https://leetcode.com/problems/clone-graph/

14.2) https://leetcode.com/problems/number-of-islands/ ( + union find)

14.3) https://leetcode.com/problems/graph-valid-tree/ ( + union find)

14.4) https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/

14.5) https://leetcode.com/problems/longest-increasing-path-in-a-matrix/

14.6) https://leetcode.com/problems/pacific-atlantic-water-flow/

14.7) https://leetcode.com/problems/sum-of-distances-in-tree/

14.8) https://leetcode.com/problems/evaluate-division/ ( shortest path)

14.9) https://leetcode.com/problems/possible-bipartition/

14.10) https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/

14.5) https://leetcode.com/problems/maximum-path-quality-of-a-graph/

14.6) https://leetcode.com/problems/reconstruct-itinerary/

14.7) https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting/

14.8) https://leetcode.com/problems/number-of-good-paths/

15. Topological sort

15.1) https://leetcode.com/problems/course-schedule/

15.2) https://leetcode.com/problems/alien-dictionary/

15.3) https://leetcode.com/problems/design-excel-sum-formula/

15.4) https://leetcode.com/problems/course-schedule-ii/

15.5)https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/

16. Trie

16.1) https://leetcode.com/problems/implement-trie-prefix-tree/

16.2) https://leetcode.com/problems/design-add-and-search-words-data-structure/

16.3) https://leetcode.com/problems/word-search/

16.4) https://leetcode.com/problems/word-search-ii/

16.5) https://leetcode.com/problems/top-k-frequent-words/

16.6) https://leetcode.com/problems/number-of-matching-subsequences/

16.7) https://leetcode.com/problems/longest-common-prefix/

16.8) https://leetcode.com/problems/palindrome-pairs/

16.9) https://leetcode.com/problems/lexicographical-numbers/

16.10) https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/

16.11) https://leetcode.com/problems/search-suggestions-system/

16.12) https://leetcode.com/problems/concatenated-words/

17. Heaps

17.1) https://leetcode.com/problems/find-median-from-data-stream/

17.2) https://leetcode.com/problems/top-k-frequent-elements/

17.3) https://leetcode.com/problems/find-k-closest-elements/

17.4) https://leetcode.com/problems/minimum-number-of-refueling-stops/

17.5) https://leetcode.com/problems/the-skyline-problem/

17.6) https://leetcode.com/problems/reorganize-string/

17.7) https://leetcode.com/problems/maximum-performance-of-a-team/

17.8) https://leetcode.com/problems/task-scheduler/

17.9) https://leetcode.com/problems/single-threaded-cpu/

18. Bit Manipulation

18.1) https://leetcode.com/problems/sum-of-two-integers/

18.2) https://leetcode.com/problems/power-of-two/

18.3) https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers/

18.4) https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits/

18.5) https://leetcode.com/problems/beautiful-arrangement/

18.6) https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/

19. Union find

19.1) https://leetcode.com/problems/find-if-path-exists-in-graph/

19.2) https://leetcode.com/problems/max-area-of-island/

19.3) https://leetcode.com/problems/longest-consecutive-sequence/

19.4) https://leetcode.com/problems/making-a-large-island/

19.5) https://leetcode.com/problems/accounts-merge/

19.6) https://leetcode.com/problems/satisfiability-of-equality-equations/

19.7) https://leetcode.com/problems/number-of-distinct-islands/

20.) Greedy

20.1) https://leetcode.com/problems/minimum-number-of-moves-to-make-palindrome/

20.2) https://leetcode.com/problems/break-a-palindrome/

20.3) https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/

20.4) https://leetcode.com/problems/longest-palindrome/

20.5) https://leetcode.com/problems/gas-station/

21.) Design

21.1) https://leetcode.com/problems/design-file-system/

21.2) https://leetcode.com/problems/design-in-memory-file-system/

21.3) https://leetcode.com/problems/insert-delete-getrandom-o1/

21.4) https://leetcode.com/problems/design-hashmap/

--

--

No responses yet