15
15
- [ Merge Intervals] ( #pattern-merge-intervals )
16
16
- [ Modified Binary Search] ( #pattern-modified-binary-search )
17
17
- [ Sliding Window] ( #pattern-sliding-window )
18
+ - [ Top K Elements] ( #pattern-top-k-elements )
18
19
- [ Topological Sort] ( #pattern-topological-sort )
19
20
- [ Tree Breadth First Search] ( #pattern-tree-breadth-first-search )
20
21
- [ Tree Depth First Search] ( #pattern-tree-depth-first-search )
21
- - [ Top K Elements] ( #pattern-top-k-elements )
22
22
- [ Two Heaps] ( #pattern-two-heaps )
23
23
- [ Two Pointers] ( #pattern-two-pointers )
24
24
- [ Tips to Consider] ( #tips-to-consider )
@@ -67,49 +67,73 @@ Other useful Java methods include `substring()`, `toCharArray()`, `Math.max()`,
67
67
68
68
## Question List
69
69
70
- ### Pattern: Sliding Window
70
+ ### Pattern: Arrays
71
71
72
- The sliding window approach can be found under ` 1. Sliding Window ` [ here] .
72
+ #### Easy:
73
+
74
+ 1 . Missing Number: https://leetcode.com/problems/missing-number/
75
+ 1 . Find All Numbers Disappeared in an Array: https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/
76
+ 1 . Single Number: https://leetcode.com/problems/single-number/
73
77
74
78
#### Medium:
75
79
76
- 1 . Minimum Size Subarray Sum: https://leetcode.com/problems/minimum-size-subarray-sum/
77
- 1 . Fruit Into Baskets: https://leetcode.com/problems/fruit-into-baskets/
78
- 1 . Permutation in String: https://leetcode.com/problems/permutation-in-string/
79
- 1 . Longest Repeating Character Replacement: https://leetcode.com/problems/longest-repeating-character-replacement/
80
+ 1 . Find the Duplicate Number: https://leetcode.com/problems/find-the-duplicate-number/
81
+ 1 . Find All Duplicates in an Array: https://leetcode.com/problems/find-all-duplicates-in-an-array/
80
82
81
83
#### Hard:
82
84
83
- 1 . Sliding Window Maximum: https://leetcode.com/problems/sliding-window-maximum/
84
- 1 . Longest Substring Without Repeating Characters: https://leetcode.com/problems/longest-substring-without-repeating-characters/
85
- 1 . Minimum Number of K Consecutive Bit Flips: https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/
86
- 1 . Unique Letter String: https://leetcode.com/problems/unique-letter-string/
87
- 1 . Minimum Window Substring: https://leetcode.com/problems/minimum-window-substring/
88
- 1 . Substring with Concatenation of All Words: https://leetcode.com/problems/substring-with-concatenation-of-all-words/
85
+ 1 . First Missing Positive: https://leetcode.com/problems/first-missing-positive/
89
86
90
- ### Pattern: Two Pointers
87
+ ### Pattern: Backtracking
91
88
92
- The two pointer approach can be found under ` 2. Two Pointers or Iterators ` [ here] .
89
+ The backtracking technique can be found under ` 10. Subsets ` [ here] .
93
90
94
91
#### Easy:
95
92
96
- 1 . Two Sum: https://leetcode.com/problems/two-sum/
97
- 1 . Remove Duplicates from Sorted List: https://leetcode.com/problems/remove-duplicates-from-sorted-list/
98
- 1 . Squares of a Sorted Array: https://leetcode.com/problems/squares-of-a-sorted-array/
99
- 1 . Backspace String Compare: https://leetcode.com/problems/backspace-string-compare
93
+ 1 . Letter Case Permutation: https://leetcode.com/problems/letter-case-permutation/
100
94
101
95
#### Medium:
102
96
103
- 1 . 3 Sum: https://leetcode.com/problems/3sum/
104
- 1 . 3 Sum Closest: https://leetcode.com/problems/3sum-closest/
105
- 1 . Subarrays with Product Less than K: https://leetcode.com/problems/subarray-product-less-than-k/
106
- 1 . Sort Colours: https://leetcode.com/problems/sort-colors/
97
+ 1 . Subsets: https://leetcode.com/problems/subsets/
98
+ 1 . Subsets II: https://leetcode.com/problems/subsets-ii/
99
+ 1 . Permutations: https://leetcode.com/problems/permutations/
100
+ 1 . Permutations II: https://leetcode.com/problems/permutations-ii/
101
+ 1 . Combinations: https://leetcode.com/problems/combinations/
102
+ 1 . Combination Sum: https://leetcode.com/problems/combination-sum/
103
+ 1 . Combination Sum II: https://leetcode.com/problems/combination-sum-ii/
104
+ 1 . Combination Sum III: https://leetcode.com/problems/combination-sum-iii/
105
+ 1 . Generate Parentheses: https://leetcode.com/problems/generate-parentheses/
106
+ 1 . Target Sum: https://leetcode.com/problems/target-sum/
107
+ 1 . Palindrome Partitioning: https://leetcode.com/problems/palindrome-partitioning/
108
+ 1 . Letter Combinations of a Phone Number: https://leetcode.com/problems/letter-combinations-of-a-phone-number/
109
+ 1 . Generalized Abbreviation: https://leetcode.com/problems/generalized-abbreviation/
107
110
108
111
#### Hard:
109
112
110
- 1 . Minimum Window Substring: https://leetcode.com/problems/minimum-window-substring/
111
- 1 . Trapping Rain Water: https://leetcode.com/problems/trapping-rain-water/
112
- 1 . Container With Most Water: https://leetcode.com/problems/container-with-most-water/
113
+ 1 . Sudoku Solver: https://leetcode.com/problems/sudoku-solver/
114
+ 1 . N-Queens: https://leetcode.com/problems/n-queens/
115
+
116
+ ### Pattern : Dynamic Programming
117
+
118
+ Dynamic programming guides can be found on [ topcoder] and the [ Back To Back SWE
119
+ YouTube channel] .
120
+
121
+ #### Easy:
122
+
123
+ 1 . Climbing Stairs: https://leetcode.com/problems/climbing-stairs/
124
+ 1 . House Robber: https://leetcode.com/problems/house-robber/
125
+ 1 . Maximum Subarray: https://leetcode.com/problems/maximum-subarray/
126
+ 1 . Range Sum Query - Immutable: https://leetcode.com/problems/range-sum-query-immutable/
127
+
128
+ #### Medium:
129
+
130
+ 1 . Coin Change: https://leetcode.com/problems/coin-change/
131
+ 1 . Longest Increasing Subsequence: https://leetcode.com/problems/longest-increasing-subsequence/
132
+ 1 . Number of Longest Increasing Subsequence: https://leetcode.com/problems/number-of-longest-increasing-subsequence/
133
+ 1 . Partition Equal Subset Sum: https://leetcode.com/problems/partition-equal-subset-sum/
134
+ 1 . Partition to K Equal Sum Subsets: https://leetcode.com/problems/partition-to-k-equal-sum-subsets/
135
+ 1 . Best Time to Buy and Sell Stock with Cooldown: https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/
136
+ 1 . Counting Bits: https://leetcode.com/problems/counting-bits/
113
137
114
138
### Pattern: Fast & Slow Pointers
115
139
@@ -129,6 +153,39 @@ The fast & slow pointer approach can be found under `3. Fast and Slow pointers`
129
153
1 . Add Two Numbers: https://leetcode.com/problems/add-two-numbers/ ,
130
154
1 . Sort List: https://leetcode.com/problems/sort-list/
131
155
156
+ ### Pattern: In-place Reversal of a Linked List
157
+
158
+ The in-place reveral technique can be found under ` 6. In-place reversal of linked list ` [ here] .
159
+
160
+ #### Easy:
161
+
162
+ 1 . Reverse Linked List: https://leetcode.com/problems/reverse-linked-list/
163
+
164
+ #### Medium:
165
+
166
+ 1 . Reverse Linked List II: https://leetcode.com/problems/reverse-linked-list-ii/
167
+ 1 . Rotate List: https://leetcode.com/problems/rotate-list/
168
+ 1 . Swap Nodes in Pairs: https://leetcode.com/problems/swap-nodes-in-pairs/
169
+ 1 . Odd Even Linked List: https://leetcode.com/problems/odd-even-linked-list/
170
+
171
+ #### Hard:
172
+
173
+ 1 . Reverse Nodes in k-Group: https://leetcode.com/problems/reverse-nodes-in-k-group/
174
+
175
+ ### Pattern: K-Way Merge
176
+
177
+ The k-way merge technique can be found under ` 13. K-way Merge ` [ here] .
178
+
179
+ #### Medium:
180
+
181
+ 1 . Kth Smallest Element in a Sorted Matrix: https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/
182
+ 1 . Find K Pairs with Smallest Sums: https://leetcode.com/problems/find-k-pairs-with-smallest-sums/
183
+
184
+ #### Hard:
185
+
186
+ 1 . Merge k Sorted Lists: https://leetcode.com/problems/merge-k-sorted-lists/
187
+ 1 . Smallest Range Covering Elements from K Lists: https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/
188
+
132
189
### Pattern: Merge Intervals
133
190
134
191
The merge interval approach can be found under ` 4. Merge Intervals ` [ here] .
@@ -151,41 +208,82 @@ The merge interval approach can be found under `4. Merge Intervals` [here].
151
208
1 . Insert Interval: https://leetcode.com/problems/insert-interval/
152
209
1 . Employee Free Time: https://leetcode.com/problems/employee-free-time/
153
210
154
- ### Pattern: Arrays
211
+ ### Pattern: Modified Binary Search
212
+
213
+ The modified binary search algorithm can be found under ` 11. Modified binary search ` [ here] .
155
214
156
215
#### Easy:
157
216
158
- 1 . Missing Number : https://leetcode.com/problems/missing-number /
159
- 1 . Find All Numbers Disappeared in an Array : https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array /
160
- 1 . Single Number : https://leetcode.com/problems/single-number /
217
+ 1 . Binary Search : https://leetcode.com/problems/binary-search /
218
+ 1 . Find Smallest Letter Greater Than Target : https://leetcode.com/problems/find-smallest-letter-greater-than-target /
219
+ 1 . Peak Index in a Mountain Array : https://leetcode.com/problems/peak-index-in-a-mountain-array /
161
220
162
221
#### Medium:
163
222
164
- 1 . Find the Duplicate Number: https://leetcode.com/problems/find-the-duplicate-number/
165
- 1 . Find All Duplicates in an Array: https://leetcode.com/problems/find-all-duplicates-in-an-array/
223
+ 1 . Find Peak Element: https://leetcode.com/problems/find-peak-element/
224
+ 1 . Search in Rotated Sorted Array: https://leetcode.com/problems/search-in-rotated-sorted-array/
225
+ 1 . Search in Rotated Sorted Array II: https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
226
+ 1 . Search a 2D Matrix: https://leetcode.com/problems/search-a-2d-matrix/
227
+ 1 . Search a 2D Matrix II: https://leetcode.com/problems/search-a-2d-matrix-ii/
166
228
167
229
#### Hard:
168
230
169
- 1 . First Missing Positive : https://leetcode.com/problems/first-missing-positive /
231
+ 1 . Count of Range Sum : https://leetcode.com/problems/count-of-range-sum /
170
232
171
- ### Pattern: In-place Reversal of a Linked List
233
+ ### Pattern: Sliding Window
172
234
173
- The in-place reveral technique can be found under ` 6. In-place reversal of linked list ` [ here] .
235
+ The sliding window approach can be found under ` 1. Sliding Window ` [ here] .
174
236
175
- #### Easy :
237
+ #### Medium :
176
238
177
- 1 . Reverse Linked List: https://leetcode.com/problems/reverse-linked-list/
239
+ 1 . Minimum Size Subarray Sum: https://leetcode.com/problems/minimum-size-subarray-sum/
240
+ 1 . Fruit Into Baskets: https://leetcode.com/problems/fruit-into-baskets/
241
+ 1 . Permutation in String: https://leetcode.com/problems/permutation-in-string/
242
+ 1 . Longest Repeating Character Replacement: https://leetcode.com/problems/longest-repeating-character-replacement/
243
+
244
+ #### Hard:
245
+
246
+ 1 . Sliding Window Maximum: https://leetcode.com/problems/sliding-window-maximum/
247
+ 1 . Longest Substring Without Repeating Characters: https://leetcode.com/problems/longest-substring-without-repeating-characters/
248
+ 1 . Minimum Number of K Consecutive Bit Flips: https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/
249
+ 1 . Unique Letter String: https://leetcode.com/problems/unique-letter-string/
250
+ 1 . Minimum Window Substring: https://leetcode.com/problems/minimum-window-substring/
251
+ 1 . Substring with Concatenation of All Words: https://leetcode.com/problems/substring-with-concatenation-of-all-words/
252
+
253
+ ### Pattern: Top 'K' Elements
254
+
255
+ The top K element technique can be found under ` 12. Top K elements ` [ here] .
178
256
179
257
#### Medium:
180
258
181
- 1 . Reverse Linked List II: https://leetcode.com/problems/reverse-linked-list-ii/
182
- 1 . Rotate List: https://leetcode.com/problems/rotate-list/
183
- 1 . Swap Nodes in Pairs: https://leetcode.com/problems/swap-nodes-in-pairs/
184
- 1 . Odd Even Linked List: https://leetcode.com/problems/odd-even-linked-list/
259
+ 1 . Kth Smallest Element in a BST: https://leetcode.com/problems/kth-smallest-element-in-a-bst/
260
+ 1 . K Closest Points to Origin: https://leetcode.com/problems/k-closest-points-to-origin/
261
+ 1 . Top K Frequent Elements: https://leetcode.com/problems/top-k-frequent-elements/
262
+ 1 . Sort Characters By Frequency: https://leetcode.com/problems/sort-characters-by-frequency/
263
+ 1 . Kth Largest Element in an Array: https://leetcode.com/problems/kth-largest-element-in-an-array/
264
+ 1 . Find K Closest Elements: https://leetcode.com/problems/find-k-closest-elements/
265
+ 1 . Reorganize String: https://leetcode.com/problems/reorganize-string/
185
266
186
267
#### Hard:
187
268
188
- 1 . Reverse Nodes in k-Group: https://leetcode.com/problems/reverse-nodes-in-k-group/
269
+ 1 . Rearrange String k Distance Apart: https://leetcode.com/problems/rearrange-string-k-distance-apart
270
+ 1 . Course Schedule III: https://leetcode.com/problems/course-schedule-iii/
271
+ 1 . Maximum Frequency Stack: https://leetcode.com/problems/maximum-frequency-stack/
272
+
273
+ ### Pattern: Topological Sort
274
+
275
+ The topological sort algorithm can be found under ` 14. Topological sort ` [ here] .
276
+
277
+ #### Medium:
278
+
279
+ 1 . Course Schedule: https://leetcode.com/problems/course-schedule/
280
+ 1 . Course Schedule II: https://leetcode.com/problems/course-schedule-ii/
281
+ 1 . Minimum Height Trees: https://leetcode.com/problems/minimum-height-trees/
282
+
283
+ #### Hard:
284
+
285
+ 1 . Alien Dictionary: https://leetcode.com/problems/alien-dictionary
286
+ 1 . Sequence Reconstruction: https://leetcode.com/problems/sequence-reconstruction
189
287
190
288
### Pattern: Tree Breadth First Search
191
289
@@ -249,127 +347,29 @@ The two heaps approach can be found under `9. Two heaps` [here].
249
347
1 . Sliding Window Median: https://leetcode.com/problems/sliding-window-median/
250
348
1 . IPO: https://leetcode.com/problems/ipo/
251
349
252
- ### Pattern: Backtracking
253
-
254
- The backtracking technique can be found under ` 10. Subsets ` [ here] .
255
-
256
- #### Easy:
257
-
258
- 1 . Letter Case Permutation: https://leetcode.com/problems/letter-case-permutation/
259
-
260
- #### Medium:
261
-
262
- 1 . Subsets: https://leetcode.com/problems/subsets/
263
- 1 . Subsets II: https://leetcode.com/problems/subsets-ii/
264
- 1 . Permutations: https://leetcode.com/problems/permutations/
265
- 1 . Permutations II: https://leetcode.com/problems/permutations-ii/
266
- 1 . Combinations: https://leetcode.com/problems/combinations/
267
- 1 . Combination Sum: https://leetcode.com/problems/combination-sum/
268
- 1 . Combination Sum II: https://leetcode.com/problems/combination-sum-ii/
269
- 1 . Combination Sum III: https://leetcode.com/problems/combination-sum-iii/
270
- 1 . Generate Parentheses: https://leetcode.com/problems/generate-parentheses/
271
- 1 . Target Sum: https://leetcode.com/problems/target-sum/
272
- 1 . Palindrome Partitioning: https://leetcode.com/problems/palindrome-partitioning/
273
- 1 . Letter Combinations of a Phone Number: https://leetcode.com/problems/letter-combinations-of-a-phone-number/
274
- 1 . Generalized Abbreviation: https://leetcode.com/problems/generalized-abbreviation/
275
-
276
- #### Hard:
277
-
278
- 1 . Sudoku Solver: https://leetcode.com/problems/sudoku-solver/
279
- 1 . N-Queens: https://leetcode.com/problems/n-queens/
280
-
281
- ### Pattern: Modified Binary Search
282
-
283
- The modified binary search algorithm can be found under ` 11. Modified binary search ` [ here] .
284
-
285
- #### Easy:
286
-
287
- 1 . Binary Search: https://leetcode.com/problems/binary-search/
288
- 1 . Find Smallest Letter Greater Than Target: https://leetcode.com/problems/find-smallest-letter-greater-than-target/
289
- 1 . Peak Index in a Mountain Array: https://leetcode.com/problems/peak-index-in-a-mountain-array/
290
-
291
- #### Medium:
292
-
293
- 1 . Find Peak Element: https://leetcode.com/problems/find-peak-element/
294
- 1 . Search in Rotated Sorted Array: https://leetcode.com/problems/search-in-rotated-sorted-array/
295
- 1 . Search in Rotated Sorted Array II: https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
296
- 1 . Search a 2D Matrix: https://leetcode.com/problems/search-a-2d-matrix/
297
- 1 . Search a 2D Matrix II: https://leetcode.com/problems/search-a-2d-matrix-ii/
298
-
299
- #### Hard:
300
-
301
- 1 . Count of Range Sum: https://leetcode.com/problems/count-of-range-sum/
302
-
303
- ### Pattern: Top 'K' Elements
304
-
305
- The top K element technique can be found under ` 12. Top K elements ` [ here] .
306
-
307
- #### Medium:
308
-
309
- 1 . Kth Smallest Element in a BST: https://leetcode.com/problems/kth-smallest-element-in-a-bst/
310
- 1 . K Closest Points to Origin: https://leetcode.com/problems/k-closest-points-to-origin/
311
- 1 . Top K Frequent Elements: https://leetcode.com/problems/top-k-frequent-elements/
312
- 1 . Sort Characters By Frequency: https://leetcode.com/problems/sort-characters-by-frequency/
313
- 1 . Kth Largest Element in an Array: https://leetcode.com/problems/kth-largest-element-in-an-array/
314
- 1 . Find K Closest Elements: https://leetcode.com/problems/find-k-closest-elements/
315
- 1 . Reorganize String: https://leetcode.com/problems/reorganize-string/
316
-
317
- #### Hard:
318
-
319
- 1 . Rearrange String k Distance Apart: https://leetcode.com/problems/rearrange-string-k-distance-apart
320
- 1 . Course Schedule III: https://leetcode.com/problems/course-schedule-iii/
321
- 1 . Maximum Frequency Stack: https://leetcode.com/problems/maximum-frequency-stack/
322
-
323
- ### Pattern: K-Way Merge
324
-
325
- The k-way merge technique can be found under ` 13. K-way Merge ` [ here] .
326
-
327
- #### Medium:
328
-
329
- 1 . Kth Smallest Element in a Sorted Matrix: https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/
330
- 1 . Find K Pairs with Smallest Sums: https://leetcode.com/problems/find-k-pairs-with-smallest-sums/
331
-
332
- #### Hard:
333
-
334
- 1 . Merge k Sorted Lists: https://leetcode.com/problems/merge-k-sorted-lists/
335
- 1 . Smallest Range Covering Elements from K Lists: https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/
336
-
337
- ### Pattern : Dynamic Programming
350
+ ### Pattern: Two Pointers
338
351
339
- Dynamic programming guides can be found on [ topcoder] and the [ Back To Back SWE
340
- YouTube channel] .
352
+ The two pointer approach can be found under ` 2. Two Pointers or Iterators ` [ here] .
341
353
342
354
#### Easy:
343
355
344
- 1 . Climbing Stairs: https://leetcode.com/problems/climbing-stairs/
345
- 1 . House Robber: https://leetcode.com/problems/house-robber/
346
- 1 . Maximum Subarray: https://leetcode.com/problems/maximum-subarray/
347
- 1 . Range Sum Query - Immutable: https://leetcode.com/problems/range-sum-query-immutable/
348
-
349
- #### Medium:
350
-
351
- 1 . Coin Change: https://leetcode.com/problems/coin-change/
352
- 1 . Longest Increasing Subsequence: https://leetcode.com/problems/longest-increasing-subsequence/
353
- 1 . Number of Longest Increasing Subsequence: https://leetcode.com/problems/number-of-longest-increasing-subsequence/
354
- 1 . Partition Equal Subset Sum: https://leetcode.com/problems/partition-equal-subset-sum/
355
- 1 . Partition to K Equal Sum Subsets: https://leetcode.com/problems/partition-to-k-equal-sum-subsets/
356
- 1 . Best Time to Buy and Sell Stock with Cooldown: https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/
357
- 1 . Counting Bits: https://leetcode.com/problems/counting-bits/
358
-
359
- ### Pattern: Topological Sort
360
-
361
- The topological sort algorithm can be found under ` 14. Topological sort ` [ here] .
356
+ 1 . Two Sum: https://leetcode.com/problems/two-sum/
357
+ 1 . Remove Duplicates from Sorted List: https://leetcode.com/problems/remove-duplicates-from-sorted-list/
358
+ 1 . Squares of a Sorted Array: https://leetcode.com/problems/squares-of-a-sorted-array/
359
+ 1 . Backspace String Compare: https://leetcode.com/problems/backspace-string-compare
362
360
363
361
#### Medium:
364
362
365
- 1 . Course Schedule: https://leetcode.com/problems/course-schedule/
366
- 1 . Course Schedule II: https://leetcode.com/problems/course-schedule-ii/
367
- 1 . Minimum Height Trees: https://leetcode.com/problems/minimum-height-trees/
363
+ 1 . 3 Sum: https://leetcode.com/problems/3sum/
364
+ 1 . 3 Sum Closest: https://leetcode.com/problems/3sum-closest/
365
+ 1 . Subarrays with Product Less than K: https://leetcode.com/problems/subarray-product-less-than-k/
366
+ 1 . Sort Colours: https://leetcode.com/problems/sort-colors/
368
367
369
368
#### Hard:
370
369
371
- 1 . Alien Dictionary: https://leetcode.com/problems/alien-dictionary
372
- 1 . Sequence Reconstruction: https://leetcode.com/problems/sequence-reconstruction
370
+ 1 . Minimum Window Substring: https://leetcode.com/problems/minimum-window-substring/
371
+ 1 . Trapping Rain Water: https://leetcode.com/problems/trapping-rain-water/
372
+ 1 . Container With Most Water: https://leetcode.com/problems/container-with-most-water/
373
373
374
374
## Tips to Consider
375
375
0 commit comments