Repository navigation
Expand file tree
/
Copy pathproblems.json
More file actions
5450 lines (5450 loc) · 168 KB
/
Copy pathproblems.json
File metadata and controls
5450 lines (5450 loc) · 168 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[
{
"platform": "leetcode",
"id": "1",
"title": "Two Sum",
"slug": "two-sum",
"url": "https://leetcode.com/problems/two-sum/",
"difficulty": "Easy",
"tags": [
"Array",
"Hash Table"
],
"pattern": "Arrays & Hashing",
"key_idea": "One pass with a value→index map; look up target − x before inserting x.",
"time": "O(n)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0001. Two Sum.java"
},
{
"platform": "leetcode",
"id": "2",
"title": "Add Two Numbers",
"slug": "add-two-numbers",
"url": "https://leetcode.com/problems/add-two-numbers/",
"difficulty": "Medium",
"tags": [
"Linked List",
"Math",
"Recursion"
],
"pattern": "Linked List",
"key_idea": "Walk both lists digit by digit with a carry, appending each sum mod 10 to a dummy-headed result list.",
"time": "O(max(m, n))",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0002. Add Two Numbers.java"
},
{
"platform": "leetcode",
"id": "3",
"title": "Longest Substring Without Repeating Characters",
"slug": "longest-substring-without-repeating-characters",
"url": "https://leetcode.com/problems/longest-substring-without-repeating-characters/",
"difficulty": "Medium",
"tags": [
"Hash Table",
"String",
"Sliding Window"
],
"pattern": "Sliding Window",
"key_idea": "Grow the window rightward; while the new char is already in the set, drop chars from the left; track the widest window.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0003. Longest Substring Without Repeating Characters.java"
},
{
"platform": "leetcode",
"id": "7",
"title": "Reverse Integer",
"slug": "reverse-integer",
"url": "https://leetcode.com/problems/reverse-integer/",
"difficulty": "Medium",
"tags": [
"Math"
],
"pattern": "Math",
"key_idea": "Pop the last digit and push it onto a long accumulator, returning 0 as soon as it leaves the int range.",
"time": "O(log x)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0007. Reverse Integer.java"
},
{
"platform": "leetcode",
"id": "9",
"title": "Palindrome Number",
"slug": "palindrome-number",
"url": "https://leetcode.com/problems/palindrome-number/",
"difficulty": "Easy",
"tags": [
"Math"
],
"pattern": "Math",
"key_idea": "Write the digits in reverse order into a string and compare it with the number's own string.",
"time": "O(log x)",
"space": "O(log x)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0009. Palindrome Number.java"
},
{
"platform": "leetcode",
"id": "11",
"title": "Container With Most Water",
"slug": "container-with-most-water",
"url": "https://leetcode.com/problems/container-with-most-water/",
"difficulty": "Medium",
"tags": [
"Array",
"Two Pointers",
"Greedy"
],
"pattern": "Two Pointers",
"key_idea": "Start at both ends, record the area, then move the shorter wall inward because it caps the height.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0011. Container With Most Water.java"
},
{
"platform": "leetcode",
"id": "13",
"title": "Roman to Integer",
"slug": "roman-to-integer",
"url": "https://leetcode.com/problems/roman-to-integer/",
"difficulty": "Easy",
"tags": [
"Hash Table",
"Math",
"String"
],
"pattern": "Strings",
"key_idea": "Add each symbol's value, but subtract it when the next symbol is larger.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0013. Roman to Integer.java"
},
{
"platform": "leetcode",
"id": "14",
"title": "Longest Common Prefix",
"slug": "longest-common-prefix",
"url": "https://leetcode.com/problems/longest-common-prefix/",
"difficulty": "Easy",
"tags": [
"Array",
"String",
"Trie"
],
"pattern": "Strings",
"key_idea": "Take the first word as the prefix and trim its last char until every other word starts with it.",
"time": "O((n + m)·m^2)",
"space": "O(m)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0014. Longest Common Prefix.java"
},
{
"platform": "leetcode",
"id": "15",
"title": "3Sum",
"slug": "3sum",
"url": "https://leetcode.com/problems/3sum/",
"difficulty": "Medium",
"tags": [
"Array",
"Two Pointers",
"Sorting"
],
"pattern": "Two Pointers",
"key_idea": "Sort, fix each distinct anchor, then move two pointers inward toward a zero sum, skipping duplicate values.",
"time": "O(n^2)",
"space": "O(log n)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0015. 3Sum.java"
},
{
"platform": "leetcode",
"id": "19",
"title": "Remove Nth Node From End of List",
"slug": "remove-nth-node-from-end-of-list",
"url": "https://leetcode.com/problems/remove-nth-node-from-end-of-list/",
"difficulty": "Medium",
"tags": [
"Linked List",
"Two Pointers"
],
"pattern": "Two Pointers",
"key_idea": "From a dummy node, move a fast pointer n + 1 steps ahead, advance both until fast ends, then unlink slow.next.",
"time": "O(sz)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0019. Remove Nth Node From End of List.java"
},
{
"platform": "leetcode",
"id": "20",
"title": "Valid Parentheses",
"slug": "valid-parentheses",
"url": "https://leetcode.com/problems/valid-parentheses/",
"difficulty": "Easy",
"tags": [
"String",
"Stack",
"Bracket Sequences"
],
"pattern": "Stack",
"key_idea": "Push opening brackets; each closing bracket must match the top; the string is valid if the stack ends empty.",
"time": "O(n)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0020. Valid Parentheses.java"
},
{
"platform": "leetcode",
"id": "21",
"title": "Merge Two Sorted Lists",
"slug": "merge-two-sorted-lists",
"url": "https://leetcode.com/problems/merge-two-sorted-lists/",
"difficulty": "Easy",
"tags": [
"Linked List",
"Recursion"
],
"pattern": "Linked List",
"key_idea": "Splice the smaller head onto a dummy tail until one list runs out, then attach the remainder.",
"time": "O(m + n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0021. Merge Two Sorted Lists.java"
},
{
"platform": "leetcode",
"id": "22",
"title": "Generate Parentheses",
"slug": "generate-parentheses",
"url": "https://leetcode.com/problems/generate-parentheses/",
"difficulty": "Medium",
"tags": [
"String",
"Dynamic Programming",
"Backtracking",
"Bracket Sequences"
],
"pattern": "Backtracking",
"key_idea": "Build strings char by char, adding '(' while fewer than n are open and ')' while it stays balanced.",
"time": "O(n·4^n / √n)",
"space": "O(n^2)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0022. Generate Parentheses.java"
},
{
"platform": "leetcode",
"id": "23",
"title": "Merge k Sorted Lists",
"slug": "merge-k-sorted-lists",
"url": "https://leetcode.com/problems/merge-k-sorted-lists/",
"difficulty": "Hard",
"tags": [
"Linked List",
"Divide and Conquer",
"Heap (Priority Queue)",
"Merge Sort",
"Tournament Sort"
],
"pattern": "Heap / Priority Queue",
"key_idea": "Seed a min-heap with every list head; pop the smallest node, append it, and push its successor.",
"time": "O(N log k)",
"space": "O(k)",
"language": "Java",
"path": "LeetCode_Problems/Java/hard/0023. Merge k Sorted Lists.java"
},
{
"platform": "leetcode",
"id": "24",
"title": "Swap Nodes in Pairs",
"slug": "swap-nodes-in-pairs",
"url": "https://leetcode.com/problems/swap-nodes-in-pairs/",
"difficulty": "Medium",
"tags": [
"Linked List",
"Recursion"
],
"pattern": "Linked List",
"key_idea": "From a dummy node, rewire each pair A→B into B→A→rest, then step past the pair.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0024. Swap Nodes in Pairs.java"
},
{
"platform": "leetcode",
"id": "25",
"title": "Reverse Nodes in k-Group",
"slug": "reverse-nodes-in-k-group",
"url": "https://leetcode.com/problems/reverse-nodes-in-k-group/",
"difficulty": "Hard",
"tags": [
"Linked List",
"Recursion"
],
"pattern": "Linked List",
"key_idea": "Find each group's k-th node; if it exists, reverse the group in place and splice it after the previous group.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/hard/0025. Reverse Nodes in k Group.java"
},
{
"platform": "leetcode",
"id": "26",
"title": "Remove Duplicates from Sorted Array",
"slug": "remove-duplicates-from-sorted-array",
"url": "https://leetcode.com/problems/remove-duplicates-from-sorted-array/",
"difficulty": "Easy",
"tags": [
"Array",
"Two Pointers"
],
"pattern": "Two Pointers",
"key_idea": "A write index keeps one copy of each value, copying nums[i] only when it differs from nums[i − 1].",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0026. Remove Duplicates from Sorted Array.java"
},
{
"platform": "leetcode",
"id": "27",
"title": "Remove Element",
"slug": "remove-element",
"url": "https://leetcode.com/problems/remove-element/",
"difficulty": "Easy",
"tags": [
"Array",
"Two Pointers"
],
"pattern": "Two Pointers",
"key_idea": "Copy every element that is not val forward to a write index; the index is the new length.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0027. Remove Element.java"
},
{
"platform": "leetcode",
"id": "32",
"title": "Longest Valid Parentheses",
"slug": "longest-valid-parentheses",
"url": "https://leetcode.com/problems/longest-valid-parentheses/",
"difficulty": "Hard",
"tags": [
"String",
"Dynamic Programming",
"Stack",
"Bracket Sequences"
],
"pattern": "Stack",
"key_idea": "Stack indices over a -1 base; on ')' pop, then measure from the new top, or make i the base if empty.",
"time": "O(n)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/hard/0032. Longest Valid Parentheses.java"
},
{
"platform": "leetcode",
"id": "37",
"title": "Sudoku Solver",
"slug": "sudoku-solver",
"url": "https://leetcode.com/problems/sudoku-solver/",
"difficulty": "Hard",
"tags": [
"Array",
"Hash Table",
"Backtracking",
"Matrix",
"Algorithm X",
"Dancing Links"
],
"pattern": "Backtracking",
"key_idea": "Fill the first empty cell with each digit valid for its row, column and box; recurse and undo on failure.",
"time": "O(9^m)",
"space": "O(m)",
"language": "Java",
"path": "LeetCode_Problems/Java/hard/0037. Sudoku Solver.java"
},
{
"platform": "leetcode",
"id": "42",
"title": "Trapping Rain Water",
"slug": "trapping-rain-water",
"url": "https://leetcode.com/problems/trapping-rain-water/",
"difficulty": "Hard",
"tags": [
"Array",
"Two Pointers",
"Dynamic Programming",
"Stack",
"Monotonic Stack"
],
"pattern": "Two Pointers",
"key_idea": "Move the lower side inward, tracking its running max; water above a bar is that max minus its height.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/hard/0042. Trapping Rain Water.java"
},
{
"platform": "leetcode",
"id": "45",
"title": "Jump Game II",
"slug": "jump-game-ii",
"url": "https://leetcode.com/problems/jump-game-ii/",
"difficulty": "Medium",
"tags": [
"Array",
"Dynamic Programming",
"Greedy"
],
"pattern": "Greedy",
"key_idea": "Treat reach as BFS levels: track the farthest jump, and when i hits the current level's end, jump and extend it.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0045. Jump Game II.java"
},
{
"platform": "leetcode",
"id": "46",
"title": "Permutations",
"slug": "permutations",
"url": "https://leetcode.com/problems/permutations/",
"difficulty": "Medium",
"tags": [
"Array",
"Backtracking"
],
"pattern": "Backtracking",
"key_idea": "Extend the current list with each number not already in it, recurse, then remove it.",
"time": "O(n^2·n!)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0046. Permutations.java"
},
{
"platform": "leetcode",
"id": "48",
"title": "Rotate Image",
"slug": "rotate-image",
"url": "https://leetcode.com/problems/rotate-image/",
"difficulty": "Medium",
"tags": [
"Array",
"Math",
"Matrix"
],
"pattern": "Math",
"key_idea": "Transpose across the main diagonal, then reverse each row; together they rotate the matrix 90° clockwise.",
"time": "O(n^2)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0048. Rotate Image.java"
},
{
"platform": "leetcode",
"id": "49",
"title": "Group Anagrams",
"slug": "group-anagrams",
"url": "https://leetcode.com/problems/group-anagrams/",
"difficulty": "Medium",
"tags": [
"Array",
"Hash Table",
"String",
"Sorting"
],
"pattern": "Arrays & Hashing",
"key_idea": "Sort each word's letters to form a key and group the words by key in a hash map.",
"time": "O(n·k log k)",
"space": "O(n·k)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0049. Group Anagrams.java"
},
{
"platform": "leetcode",
"id": "50",
"title": "Pow(x, n)",
"slug": "powx-n",
"url": "https://leetcode.com/problems/powx-n/",
"difficulty": "Medium",
"tags": [
"Math",
"Recursion"
],
"pattern": "Math",
"key_idea": "Fast exponentiation: square x and halve the exponent, multiplying in one extra x when it is odd; negative n uses 1/x.",
"time": "O(log n)",
"space": "O(log n)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0050. Pow(x, n).java"
},
{
"platform": "leetcode",
"id": "51",
"title": "N-Queens",
"slug": "n-queens",
"url": "https://leetcode.com/problems/n-queens/",
"difficulty": "Hard",
"tags": [
"Array",
"Backtracking",
"Algorithm X"
],
"pattern": "Backtracking",
"key_idea": "Place one queen per row, skipping columns and both diagonals already marked in boolean arrays, then unmark.",
"time": "O(n·n!)",
"space": "O(n^2)",
"language": "Java",
"path": "LeetCode_Problems/Java/hard/0051. NQueens.java"
},
{
"platform": "leetcode",
"id": "54",
"title": "Spiral Matrix",
"slug": "spiral-matrix",
"url": "https://leetcode.com/problems/spiral-matrix/",
"difficulty": "Medium",
"tags": [
"Array",
"Matrix",
"Simulation"
],
"pattern": "Simulation",
"key_idea": "Walk the top, right, bottom and left edges, shrinking each bound after its edge and stopping when bounds cross.",
"time": "O(m·n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0054. Spiral Matrix.java"
},
{
"platform": "leetcode",
"id": "55",
"title": "Jump Game",
"slug": "jump-game",
"url": "https://leetcode.com/problems/jump-game/",
"difficulty": "Medium",
"tags": [
"Array",
"Dynamic Programming",
"Greedy"
],
"pattern": "Greedy",
"key_idea": "Track the farthest reachable index; fail if i ever passes it, succeed once it covers the last index.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0055. Jump Game.java"
},
{
"platform": "leetcode",
"id": "56",
"title": "Merge Intervals",
"slug": "merge-intervals",
"url": "https://leetcode.com/problems/merge-intervals/",
"difficulty": "Medium",
"tags": [
"Array",
"Sorting",
"Quicksort"
],
"pattern": "Intervals",
"key_idea": "Sort by start; extend the last merged interval while the next overlaps it, otherwise start a new one.",
"time": "O(n log n)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0056. Merge Intervals.java"
},
{
"platform": "leetcode",
"id": "57",
"title": "Insert Interval",
"slug": "insert-interval",
"url": "https://leetcode.com/problems/insert-interval/",
"difficulty": "Medium",
"tags": [
"Array"
],
"pattern": "Intervals",
"key_idea": "Copy intervals that end before the new one, absorb every overlapping interval into it, then copy the rest.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0057. Insert Interval.java"
},
{
"platform": "leetcode",
"id": "61",
"title": "Rotate List",
"slug": "rotate-list",
"url": "https://leetcode.com/problems/rotate-list/",
"difficulty": "Medium",
"tags": [
"Linked List",
"Two Pointers"
],
"pattern": "Linked List",
"key_idea": "Measure the length, close the list into a ring, then cut it after node number length − (k mod length).",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0061. Rotate List.java"
},
{
"platform": "leetcode",
"id": "67",
"title": "Add Binary",
"slug": "add-binary",
"url": "https://leetcode.com/problems/add-binary/",
"difficulty": "Easy",
"tags": [
"Math",
"String",
"Bit Manipulation",
"Simulation"
],
"pattern": "Math",
"key_idea": "Add digits from the right with a carry, appending sum mod 2, then reverse the built string.",
"time": "O(max(m, n))",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0067. Add Binary.java"
},
{
"platform": "leetcode",
"id": "69",
"title": "Sqrt(x)",
"slug": "sqrtx",
"url": "https://leetcode.com/problems/sqrtx/",
"difficulty": "Easy",
"tags": [
"Math",
"Binary Search",
"Newton's Method"
],
"pattern": "Binary Search",
"key_idea": "Binary search 0..x for the largest mid whose square, computed as a long, is at most x.",
"time": "O(log x)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0069. Sqrt(x).java"
},
{
"platform": "leetcode",
"id": "75",
"title": "Sort Colors",
"slug": "sort-colors",
"url": "https://leetcode.com/problems/sort-colors/",
"difficulty": "Medium",
"tags": [
"Array",
"Two Pointers",
"Sorting",
"Quicksort",
"Bubble Sort"
],
"pattern": "Two Pointers",
"key_idea": "Dutch national flag: a cursor swaps 0s down to the low pointer and 2s up to the high pointer, skipping 1s.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0075. Sort Colors.java"
},
{
"platform": "leetcode",
"id": "77",
"title": "Combinations",
"slug": "combinations",
"url": "https://leetcode.com/problems/combinations/",
"difficulty": "Medium",
"tags": [
"Backtracking"
],
"pattern": "Backtracking",
"key_idea": "Choose numbers in increasing order from start to n, recurse with k − 1 left, then undo the choice.",
"time": "O(k·C(n, k))",
"space": "O(k)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0077. Combinations.java"
},
{
"platform": "leetcode",
"id": "80",
"title": "Remove Duplicates from Sorted Array II",
"slug": "remove-duplicates-from-sorted-array-ii",
"url": "https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/",
"difficulty": "Medium",
"tags": [
"Array",
"Two Pointers"
],
"pattern": "Two Pointers",
"key_idea": "Write nums[i] only when it differs from the value two slots behind the write index, keeping at most two copies.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0080. Remove Duplicates from Sorted Array II.java"
},
{
"platform": "leetcode",
"id": "84",
"title": "Largest Rectangle in Histogram",
"slug": "largest-rectangle-in-histogram",
"url": "https://leetcode.com/problems/largest-rectangle-in-histogram/",
"difficulty": "Hard",
"tags": [
"Array",
"Stack",
"Monotonic Stack",
"Range Minimum/Maximum Query"
],
"pattern": "Dynamic Programming",
"key_idea": "For each bar, find the nearest shorter bar on each side by jumping through boundaries already computed; area = height × gap.",
"time": "O(n)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/hard/0084. Largest Rectanglein Histogram.java"
},
{
"platform": "leetcode",
"id": "86",
"title": "Partition List",
"slug": "partition-list",
"url": "https://leetcode.com/problems/partition-list/",
"difficulty": "Medium",
"tags": [
"Linked List",
"Two Pointers"
],
"pattern": "Linked List",
"key_idea": "Route nodes into two dummy-headed lists, below x and at least x, then join them and cut the tail.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0086. Partition List.java"
},
{
"platform": "leetcode",
"id": "88",
"title": "Merge Sorted Array",
"slug": "merge-sorted-array",
"url": "https://leetcode.com/problems/merge-sorted-array/",
"difficulty": "Easy",
"tags": [
"Array",
"Two Pointers",
"Sorting"
],
"pattern": "Two Pointers",
"key_idea": "Fill nums1 from the back, taking the larger of the two tails until nums2 is used up.",
"time": "O(m + n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0088. Merge Sorted Array.java"
},
{
"platform": "leetcode",
"id": "92",
"title": "Reverse Linked List II",
"slug": "reverse-linked-list-ii",
"url": "https://leetcode.com/problems/reverse-linked-list-ii/",
"difficulty": "Medium",
"tags": [
"Linked List"
],
"pattern": "Linked List",
"key_idea": "Walk to the node before left, then repeatedly move the node after the sublist's tail to the sublist's front.",
"time": "O(n)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0092. Reverse Linked List II.java"
},
{
"platform": "leetcode",
"id": "98",
"title": "Validate Binary Search Tree",
"slug": "validate-binary-search-tree",
"url": "https://leetcode.com/problems/validate-binary-search-tree/",
"difficulty": "Medium",
"tags": [
"Tree",
"Depth-First Search",
"Binary Search Tree",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "Recurse with an open (min, max) range kept as longs; every node must lie strictly inside its range.",
"time": "O(n)",
"space": "O(h)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0098. Validate Binary Search Tree.java"
},
{
"platform": "leetcode",
"id": "101",
"title": "Symmetric Tree",
"slug": "symmetric-tree",
"url": "https://leetcode.com/problems/symmetric-tree/",
"difficulty": "Easy",
"tags": [
"Tree",
"Depth-First Search",
"Breadth-First Search",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "Compare the two subtrees as mirrors: equal values, outer children mirror each other, inner children mirror each other.",
"time": "O(n)",
"space": "O(h)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0101. Symmetric Tree.java"
},
{
"platform": "leetcode",
"id": "102",
"title": "Binary Tree Level Order Traversal",
"slug": "binary-tree-level-order-traversal",
"url": "https://leetcode.com/problems/binary-tree-level-order-traversal/",
"difficulty": "Medium",
"tags": [
"Tree",
"Breadth-First Search",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "BFS with a queue, draining exactly the current queue size each round to collect one level.",
"time": "O(n)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0102. Binary Tree Level Order Traversal.java"
},
{
"platform": "leetcode",
"id": "103",
"title": "Binary Tree Zigzag Level Order Traversal",
"slug": "binary-tree-zigzag-level-order-traversal",
"url": "https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/",
"difficulty": "Medium",
"tags": [
"Tree",
"Breadth-First Search",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "Level-order BFS that inserts values at the front of the level list on every other level.",
"time": "O(n^2)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0103. Binary Tree Zigzag Level Order Traversal.java"
},
{
"platform": "leetcode",
"id": "104",
"title": "Maximum Depth of Binary Tree",
"slug": "maximum-depth-of-binary-tree",
"url": "https://leetcode.com/problems/maximum-depth-of-binary-tree/",
"difficulty": "Easy",
"tags": [
"Tree",
"Depth-First Search",
"Breadth-First Search",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "Depth is 1 plus the larger depth of the two subtrees; an empty tree has depth 0.",
"time": "O(n)",
"space": "O(h)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0104. Maximum Depth of Binary Tree.java"
},
{
"platform": "leetcode",
"id": "105",
"title": "Construct Binary Tree from Preorder and Inorder Traversal",
"slug": "construct-binary-tree-from-preorder-and-inorder-traversal",
"url": "https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/",
"difficulty": "Medium",
"tags": [
"Array",
"Hash Table",
"Divide and Conquer",
"Tree",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "Preorder's first value is the root; its inorder index, from a value→index map, splits both ranges into subtrees.",
"time": "O(n)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0105. Construct Binary Tree from Preorder and Inorder Traversal.java"
},
{
"platform": "leetcode",
"id": "107",
"title": "Binary Tree Level Order Traversal II",
"slug": "binary-tree-level-order-traversal-ii",
"url": "https://leetcode.com/problems/binary-tree-level-order-traversal-ii/",
"difficulty": "Medium",
"tags": [
"Tree",
"Breadth-First Search",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "Level-order BFS that inserts each finished level at the front of the result list.",
"time": "O(n^2)",
"space": "O(n)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0107. Binary Tree Level Order Traversal II.java"
},
{
"platform": "leetcode",
"id": "110",
"title": "Balanced Binary Tree",
"slug": "balanced-binary-tree",
"url": "https://leetcode.com/problems/balanced-binary-tree/",
"difficulty": "Easy",
"tags": [
"Tree",
"Depth-First Search",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "Post-order DFS returns each subtree's height and flags imbalance when child heights differ by more than 1.",
"time": "O(n)",
"space": "O(h)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0110. Balanced Binary Tree.java"
},
{
"platform": "leetcode",
"id": "112",
"title": "Path Sum",
"slug": "path-sum",
"url": "https://leetcode.com/problems/path-sum/",
"difficulty": "Easy",
"tags": [
"Tree",
"Depth-First Search",
"Breadth-First Search",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "Subtract each node's value on the way down; a leaf succeeds when the remaining sum is zero.",
"time": "O(n)",
"space": "O(h)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0112. Path Sum.java"
},
{
"platform": "leetcode",
"id": "113",
"title": "Path Sum II",
"slug": "path-sum-ii",
"url": "https://leetcode.com/problems/path-sum-ii/",
"difficulty": "Medium",
"tags": [
"Backtracking",
"Tree",
"Depth-First Search",
"Binary Tree"
],
"pattern": "Trees",
"key_idea": "DFS keeping the root-to-node path; copy it at leaves matching the remaining sum, then remove the node on return.",
"time": "O(n·h)",
"space": "O(h)",
"language": "Java",
"path": "LeetCode_Problems/Java/medium/0113. Path Sum II.java"
},
{
"platform": "leetcode",
"id": "118",
"title": "Pascal's Triangle",
"slug": "pascals-triangle",
"url": "https://leetcode.com/problems/pascals-triangle/",
"difficulty": "Easy",
"tags": [
"Array",
"Dynamic Programming"
],
"pattern": "Dynamic Programming",
"key_idea": "Each row starts and ends with 1; every inner entry is the sum of the two entries above it.",
"time": "O(numRows^2)",
"space": "O(1)",
"language": "Java",
"path": "LeetCode_Problems/Java/easy/0118. Pascal's Triangle.java"
},
{
"platform": "leetcode",
"id": "121",
"title": "Best Time to Buy and Sell Stock",
"slug": "best-time-to-buy-and-sell-stock",
"url": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock/",
"difficulty": "Easy",
"tags": [
"Array",
"Dynamic Programming"
],
"pattern": "Greedy",
"key_idea": "Track the lowest price so far and the best profit from selling at today's price.",