Skip to content

Latest commit

 

History

History
1021 lines (1014 loc) · 52.9 KB

LeetCodeSolutionIndex.md

File metadata and controls

1021 lines (1014 loc) · 52.9 KB

图解LeetCode

说明:

  • 几乎每个题目(除极简单或者不好画图的题目)用图的方式结合部分文字解释展现出来。
  • 大部分题目我都尽我所能的总结了尽可能多的解法
  • 定位到某个题目,chrome浏览器按ctrl + f然后搜索序号或者题目名字即可(非常实用,我一般都用这个方法定位到某个题目);
  • 目前项目正在初期,后面会不断完善,很多题目我都写过了,正在完善一些图解(大概200题左右)。
  • 完善做过的之后,以后大概每天增加2~4题;
  • 图片偶尔可能会加载不出来,因为github偶尔会比较慢,科学上网后不会存在这个问题;

如果觉得还不错的话,给个star ,*╯3╰ 

QQ群: 443186280。有兴趣的可以加一下。

可以一起讨论题目,我也会尽量每天发一两道题解,大家可以当做打卡,一起刷题,一起进步^_^。

列表(之前不是按照顺序写的,但是后面我会补上前面空缺的)

题号 题名和解题链接 分类 难度
1 Two Sum Hash Easy
2 Add Two Numbers List Medium
3 Longest Substring Without Repeating Characters 滑动窗口 Medium
4 Median of Two Sorted Arrays 二分 Hard
5 Longest Palindromic Substring DP、Manacher Medium
6 ZigZag Conversion 模拟 Medium
7 Reverse Integer 模拟 Easy
8 String to Integer(atoi) 模拟 Medium
9 Palindrome Number 模拟 Medium
10 Regular Expression Matching DP Hard
11 Container With Most Water 双指针 Medium
12 Integer to Roman 模拟 Medium
13 Roman to Integer 模拟 Easy
14 Longest Comman Prefix 分治、二分、Trie Easy
15 3Sum 双指针 Medium
16 3Sum Closest 双指针 Medium
17 Letter Combination of a Phone Number Search Medium
18 4Sum 双指针 Medium
19 Remove Nth Node From End of List 快慢指针 Medium
20 Valid Parentheses Stack Easy
21 Merge Two Sorted Lists List Easy
22
23
24
25
26
27
28
29
30
31 Next Permutation 模拟 Medium
32
33
34 Find First and Last Position of Element in Sorted Array 二分 Medium
35
36
37 Sudoku Solver Search Hard
38
39 Combination Sum Search Medium
40 Combination Sum II Search Medium
41
42
43
44
45
46 Permutations Search Medium
47 Permuations II Search Medium
48
49
50 Pow(x, n) Math Medium
51 N-Queens Search Hard
52 N-Queens II Search Hard
53 Maximum Subarray DP Easy
54 Spiral Matrix 模拟 Medium
55
56 Merge Intervals 贪心 Medium
57 Insert Interval 贪心 Hard
58
59
60
61
62 Unique Paths DP Medium
63 Unique Paths II DP Medium
64 Minimum Path Sum DP Medium
65
66
67
68
69
70
71
72 Edit Distance DP Hard
73
74
75 Sort Colors Sort、双指针 Medium
76
77
78 Subsets Search Medium
79 Word Search Search Medium
80
81
82
83
84 Largest Rectangle in Histogram 单调栈 Hard
85 Maximal Rectangle 单调栈 Hard
86
87
88
89
90 Subset II Search Medium
91 Decode Ways DP Medium
92
93
94
95
96
97
98 Validate Binary Search Tree Tree Medium
99
100 Same Tree Tree Easy
101 Symmetric Tree Tree Easy
102 Binary Tree Level Order Traversal Tree Medium
103 Binary Tree Zigzag Level Order Traversal Tree Medium
104 Maximum Depth of Binary Tree Tree Easy
105 Construct Binary Tree from Preorder and Inorder Traversal Tree Medium
106 Construct Binary Tree from Inorder and Postorder Traversal Tree Medium
107
108
109
110 Balanced Binary Tree Tree Easy
111
112 Path Sum Tree Easy
113 Path Sum II Tree Medium
114
115
116
117
118
119
120 Traingle DP Medium
121
122
123
124 Binary Tree Maximum Path Sum Tree Hard
125 Valid Palindrome 双指针 Easy
126 Word Ladder II Search Hard
127 Word Ladder Search Medium
128 Longest Consecutive Sequence Map
129
130
131
132
133
134
135
136 Single Number Bit Easy
137 Single Number II Bit Medium
138 Copy List with Random Pointer List Medium
139 Word Break DP Medium
140 Word Break II DP Hard
141 Linked List Cycle List Easy
142 Linked List Cycle II List Medium
143
144
145 Binary Tree Postorder Traversal Tree Hard
146 LRU Cache List、Map Hard
147
148
149 Max Points on a Line Math、Map Hard
150
151
152 Maximum Product Subarray DP Medium
153
154
155
156
157
158
159
160 Intersectin of Two Linked Lists List Easy
161
162
163
164 Maximum Gap Buckets Hard
165
166
167 Two Sum II - Input array is sorted 双指针 Easy
168
169 Majority Element Bit、分治 Easy
170
171
172
173
174 Dungeon Game DP Hard
175
176
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 Number of Islands Search、并查集 Medium
201
202
203 Remove Linked List Elements List Easy
204 Count Primes Math Easy
205
206 Reverse Linked List List Easy
207 Course Schedule 拓扑排序 Medium
208 Implement Trie Prefix Tree Trie Medium
209 Minimum Size Subarray Sum 滑动窗口 Medium
210
211 Add and Search Word - Data structure design Trie Medium
212
213
214 Shortest Palindrome KMP、Manacher Hard
215 Kth Largest Element in an Array Heap,Partition Medium
216 Combination Sum III Search、Bit Medium
217
218
219
220
221 Maximal Square DP Medium
222 LeetCode - 222. Count Complete Tree Nodes Tree Medium
223
224
225
226
227 Basic Calculator II,系列计算器和栈的题目 Stack Medium
228
229 Majority Element II Array Medium
230
231
232
233
234 Palindrome Linked List List Easy
235
236
237
238
239
240
241 Different Ways to Add Parentheses 分治、DP Medium
242 Valid Anagram Map Easy
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263 Ugly Number 模拟 Easy
264 Ugly Number II 堆、DP Medium
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283 Move Zeroes 双指针 Easy
284
285
286
287
288
289
290
291
292
293
294
295
296
297 Serialize and Deserialize Binary Tree Tree Medium
298
299
300
301
302
303 Range Sum Query - Immutable DP、线段树 Easy
304 Range Sum Query 2D - Immutable DP Medium
305
306
307 Range Sum Query - Mutable 线段树 Medium
308
309
310
311
312 Burst Balloons DP Hard
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334 Reverse String 双指针 Easy
335 Reverse Vowels of a String 双指针 Easy
336
337 Top K Frequent Elements Medium
338
339
340
341
342
343
344
345
346
347
348
349 Intersection of Two Arrays Set Easy
350 Intersection of Two Arrays II Map Easy
351
352
353
354 Russian Doll Envelopes DP Hard
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 Insert Delete GetRandom Map Medium
381 Insert Delete GetRandom O(1) - Duplicates allowed Map Hard
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399 Evaluate Division Graph Medium
400
401
402
403
404 Sum of Left Leaves Tree Easy
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 Serialize and Deserialize BST Tree Medium
450
451
452
453
454
455 Assign Cookies Greedy Easy
456
457
458
459
460 LFU Cache List、Design Hard
461 Hamming Distance Bit Easy
462
463 Island Perimerter Search、规律 Easy
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486 Predict the Winner DP Medium
487
488 Zuma Game Search Hard
489
490
491
492
493
494
495
496
497
498
499
400
501
502 IPO Heap、Greedy Hard
503
504 Base 7 模拟 Easy
505
506
507
508
509
510
511
512
513
514
515
516
517
518 Coin Change 2 DP Medium
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 Diameter of Binary Tree Tree Easy
544
545
546
547 Friend Circles DFS、并查集 Medium
548
549
550
551 Student Attendance Record I 模拟 Easy
552
553
554
555
556
557
558
559
560
561 Array Partition I Greedy、bucket Easy
562
563
564
565
566 Reshape the Matrix 模拟 Easy
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 Construct String from Binary Tree Tree Easy
607
608
609
610
611 Valid Triangle Number Greedy Medium
612
613
614
615
616
617 Merge Two Binary Trees Tree Easy
618
619
620
621 Task Scheduler Greedy Medium
622
623
624
625
626
627
628 Maximum Product of Three Numbers 模拟 Easy
629
630
631
632
633 Sum of Square Numbers Math、双指针 Easy
634
635
636
637 Average of Levels in Binary Tree Tree Easy
638
639 Decode Ways II DP Hard
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654 Maximum Binary Tree Tree Medium
655 Print Binary Tree Tree Medium
656
657 Robot Return to Origin 模拟 Easy
658
659
660
661
662
663
664 Strange Printer DP Hard
665
666
667
668
669
670
671 Second Minimum Node In a Binary Tree Tree Easy
672
673 Number of Longest Increasing Subsequence DP Medium
674
675 Cut Off Trees for Golf Event Search Hard
676 Implement Magic Dictionary Map、Trie Medium
677 Map Sum Pairs Trie Mediums
678
679
680 Valid Palindrome String Easy
681
682 Baseball Game 模拟 Easy
683
684 Redundant Connection DFS、并查集 Medium
685 Redundant Connection II 并查集 Hard
686
687 Longest Univalue Path Tree Easy
688 Knight Probability in Chessboard DP Medium
689
690
691
692 Top K Frequent Words Heap Medium
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 Find K-th Smallest Pair Distance 二分、模拟 Hard
720 Longest Word in Dictionary Trie Easy
721
722
723
724 Find Pivot Index 模拟 Easy
725 Split Linked List in Parts List Medium
726 Number of Atoms Map,递归 Hard
727
728
729 My Calendar I Map Medium
730 Count Different Palindromic Subsequences DP Hard
731
732
733 Flood Fill Search Easy
734
735 Asteroid Collision Stack Medium
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