luozhiping / leetcode

leetcode刷题笔记 python代码实现

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

leetcode

leetcode刷题笔记 (Python3\JAVA)

Easy

1.两数之和(two-sum) (code)
7.反转整数(reverse-integer) (code)
9.回文数(palindrome-number) (code)
14.最长公共前缀(longest-common-prefix) (code)
20.有效的括号(valid-parentheses) (code)
21.合并两个有序列表(merge-two-sorted-lists) (code)
53.最大子序列和(maximum-subarray) (code)
70.爬楼梯(climbing-stairs) (code)
88.合并两个有序数组(merge-sorted-array) (code)
104.二叉树的最大深度(maximum-depth-of-binary-tree) (code)
118.杨辉三角(pascals-triangle) (code)
121.买卖股票的最佳时机(best-time-to-buy-and-sell-stock) (code)
136.只出现一次的数字(single-number) (code)
141.环形链表(linked-list-cycle) (code)
155.最小栈(min-stack) (code)
169.求众数(majority-element) (code)
205.同构字符串(isomorphic-strings) (code)
206.反转链表(reverse-linked-list) (code)
217.存在重复元素(contains-duplicate) (code)
231.2的幂(power-of-two) (code)
237.删除链表中的节点(delete-node-in-a-linked-list) (code)
292.Nim游戏(nim-game) (code)
344.反转字符串(reverse-string) (code)
387.字符串中的第一个唯一字符(first-unique-character-in-a-string) (code)
509.斐波那契数(fibonacci-number) (code)
557.反转字符串中的单词 III(reverse-words-in-a-string-iii) (code)
703.数据流中的第K大元素(kth-largest-element-in-a-stream) (code)
704.二分查找(binary-search) (code)
821.字符的最短距离(shortest-distance-to-a-character) (code)
1018.可被 5 整除的二进制前缀(binary-prefix-divisible-by-5) (code)
1118.一月有多少天(number-of-days-in-a-month) (code)
1119.删去字符串中的元音(remove-vowels-from-a-string) (code)
1122.数组的相对排序(relative-sort-array) (code)
1133. 最大唯一数(largest-unique-number) (code)

Middle

3.无重复字符的最长子串(longest-substring-without-repeating-characters) (code)
5.最长回文子串(longest-palindromic-substring) (code)
6.Z 字形变换(zigzag-conversion) (code)
8.字符串转整数(string-to-integer-atoi) (code)
11.盛最多水的容器(container-with-most-water) (code)
15.三数之和(3sum) (code)
16.最接近的三数之和(3sum-closest) (code)
17.电话号码的字母组合(letter-combinations-of-a-phone-number) (code)
18.四数之和(4sum) (code)
19.删除链表的倒数第N个节点(remove-nth-node-from-end-of-list) (code)
22.括号生成(generate-parentheses) (code)
24.两两交换链表中的节点(swap-nodes-in-pairs) (code)
25.k个一组翻转链表(reverse-nodes-in-k-group) (code)
31.下一个排列(next-permutation) (code)
33.搜索旋转排列数组(search-in-rotated-sorted-array) (code)
34.在排序数组中查找元素的第一个和最后一个位置(find-first-and-last-position-of-element-in-sorted-array) (code)
36.有效的数独(valid-sudoku) (code)
39.组合总和(combination-sum) (code)
40.组合总和 II(combination-sum-ii) (code)
43.字符串相乘(multiply-strings) (code)
46.全排列(permutations) (code)
47.全排列II(permutations-ii) (code)
48.旋转图像(rotate-image) (code)
49.字母异位词分组(group-anagrams) (code)
50.Pow(x, n)(powx-n) (code)
54.螺旋矩阵(spiral-matrix) (code)
55.跳跃游戏(jump-game) (code)
56.合并区间(merge-intervals) (code)
57.插入区间(spiral-matrix-ii) (code)
59.螺旋矩阵II(spiral-matrix-ii) (code)
60.第k个排列(permutation-sequence)(code)
61.旋转链表(rotate-list)(code)
62.不同路径(unique-paths) (code)
63.不同路径 II(unique-paths-ii) (code)
64.最小路径和(minimum-path-sum) (code)
71.简化路径(simplify-path) (code)
73.矩阵置零(set-matrix-zeroes) (code)
74.搜索二维矩阵(search-a-2d-matrix) (code)
75.颜色分类(sort-colors) (code)
77.组合(combinations) (code)
78.子集(subsets) (code)
79.单词搜索(word-search) (code)
80.删除排序数组中的重复项 II(remove-duplicates-from-sorted-array-ii) (code)
81.搜索旋转排序数组 II(search-in-rotated-sorted-array-ii) (code)
82.删除排序链表中的重复元素 II(remove-duplicates-from-sorted-list-ii) (code)
86.分隔链表(partition-list) (code)
89.格雷编码(gray-code) (code)
90.子集 II(subsets-ii) (code)
91.解码方法(decode-ways) (code)
92.反转链表 II(reverse-linked-list-ii) (code)
93.复原IP地址(restore-ip-addresses) (code)
94.二叉树的中序遍历(binary-tree-inorder-traversal) (code)
95.不同的二叉搜索树 II(unique-binary-search-trees-ii) (code)
96.不同的二叉搜索树(unique-binary-search-trees) (code)
98.验证二叉搜索树(validate-binary-search-tree) (code)
102.二叉树的层次遍历(binary-tree-level-order-traversal) (code)
103.二叉树的锯齿形层次遍历(binary-tree-zigzag-level-order-traversal) (code)
105.从前序与中序遍历序列构造二叉树(construct-binary-tree-from-preorder-and-inorder-traversal) (code)
106.从中序与后序遍历序列构造二叉树(construct-binary-tree-from-inorder-and-postorder-traversal) (code)
109.有序链表转换二叉搜索树(convert-sorted-list-to-binary-search-tree) (code)
113.路径总和 II(path-sum-ii) (code)
114.二叉树展开为链表(flatten-binary-tree-to-linked-list) (code)
116.填充每个节点的下一个右侧节点指针(populating-next-right-pointers-in-each-node) (code)
117.填充每个节点的下一个右侧节点指针 II(populating-next-right-pointers-in-each-node-ii) (code)
120.三角形最小路径和(triangle) (code)
127.单词接龙(word-ladder) (code)
129.求根到叶子节点数字之和(sum-root-to-leaf-numbers) (code)
130.被围绕的区域(surrounded-regions) (code)
137.只出现一次的数字 II(single-number-ii) (code)
139.单词拆分(word-break) (code)
142.环形列表 II(linked-list-cycle-ii) (code)
143.重排链表(reorder-list) (code)
144.二叉树的前序遍历(binary-tree-preorder-traversal) (code)
146.LRU缓存机制(lru-cache) (code)
147.对链表进行插入排序(insertion-sort-list) (code)
148.排序链表(sort-list) (code)
150.逆波兰表达式求值(evaluate-reverse-polish-notation) (code)
151.翻转字符串里的单词(reverse-words-in-a-string) (code)
153.寻找旋转排序数组中的最小值(find-minimum-in-rotated-sorted-array) (code)
160.相交链表(intersection-of-two-linked-lists) (code)
162.寻找峰值(find-peak-element) (code)
165.比较版本号(compare-version-numbers) (code)
179.最大数(largest-number) (code)
186.翻转字符串里的单词 II(reverse-words-in-a-string-ii) (code)
187.重复的DNA序列(repeated-dna-sequences) (code)
199.二叉树的右视图(binary-tree-right-side-view) (code)
200.岛屿数量(number-of-islands) (code)
207.课程表(course-schedule) (code)
208.实现 Trie (前缀树)(implement-trie-prefix-tree) (code)
209.长度最小的子数组(minimum-size-subarray-sum) (code)
210.课程表 II(course-schedule-ii) (code)
213.打家劫舍 II(house-robber-ii) (code)
215.数组中的第K个最大元素(kth-largest-element-in-an-array) (code)
216.组合总和 III(combination-sum-iii) (code)
220.存在重复元素 III(contains-duplicate-iii) (code)
221.最大正方形(maximal-square) (code)
222.完全二叉树的节点个数(count-complete-tree-nodes) (code)
227.基本计算器 II(basic-calculator-ii) (code)
229.求众数 II(majority-element-ii) (code)
230.二叉搜索树中第K小的元素(kth-smallest-element-in-a-bst) (code)
236.二叉搜索树的最近公共祖先(lowest-common-ancestor-of-a-binary-tree) (code)
238.除自身以外数组的乘积(product-of-array-except-self) (code)
240.搜索二维矩阵 II(search-a-2d-matrix-ii) (code)
244.最短单词距离 II(shortest-word-distance-ii) (code)
245.最短单词距离 III(shortest-word-distance-iii) (code)
247.中心对称数 II(strobogrammatic-number-ii) (code)
253.会议室 II(meeting-rooms-ii) (code)
260.只出现一次的数字 III(single-number-iii) (code)
264.丑数 II(ugly-number-ii) (code)
274.H指数(h-index) (code)
279.完全平方数(perfect-squares) (code)
280.摆动排序(wiggle-sort) (code)
285.二叉搜索树中的顺序后继(inorder-successor-in-bst) (code)
287.寻找重复数(find-the-duplicate-number) (code)
299.猜数字游戏(bulls-and-cows) (code)
300.最长上升子序列(longest-increasing-subsequence) (code)
306.累加数(additive-number) (code)
319.灯泡开关(bulb-switcher) (code)
320.列举单词的全部缩写(generalized-abbreviation) (code)
322.零钱兑换(coin-change) (code)
328.奇偶链表(odd-even-linked-list) (code)
334.递增的三元子序列(increasing-triplet-subsequence) (code)
347.前K个高频元素(top-k-frequent-elements) (code)
357.计算各个位数不同的数字个数(count-numbers-with-unique-digits) (code)
360.有序转化数组(sort-transformed-array) (code)
361.轰炸敌人(bomb-enemy) (code)
365.水壶问题(water-and-jug-problem) (code)
371.两整数之和(sum-of-two-integers) (code)
338.比特位计数(counting-bits) (code)
376.摆动序列(wiggle-subsequence) (code)
378.有序矩阵中第K小的元素(kth-smallest-element-in-a-sorted-matrix) (code)
384.打乱数组(shuffle-an-array) (code)
386.字典序排数(lexicographical-numbers) (code)
394.字符串解码(decode-string) (code)
395.至少有K个重复字符的最长子串(longest-substring-with-at-least-k-repeating-characters) (code)
402.移掉K位数字(remove-k-digits) (code)
406.根据身高重建队列(queue-reconstruction-by-height) (code)
416.分割等和子集(partition-equal-subset-sum) (code)
419.甲板上的战舰(battleships-in-a-board) (code)
424.替换后的最长重复字符(longest-repeating-character-replacement) (code)
426.将二叉搜索树转化为排序的双向链表(convert-binary-search-tree-to-sorted-doubly-linked-list) (code)
423.从英文中重建数字(reconstruct-original-digits-from-english) (code)
436.寻找右区间(find-right-interval) (code)
442.数组中重复的数据(find-all-duplicates-in-an-array) (code)
445.两数相加 II(add-two-numbers-ii) (code)
451.根据字符出现频率排序(sort-characters-by-frequency) (code)
456.132模式(132-pattern) (code)
462.最少移动次数使数组元素相等 II(minimum-moves-to-equal-array-elements-ii) (code)
468.验证IP地址(validate-ip-address) (code)
487.最大连续1的个数 II(max-consecutive-ones-ii) (code)
491.递增子序列(increasing-subsequences) (code)
494.目标和(target-sum) (code)
495.提莫攻击(teemo-attacking) (code)
498.对角线遍历(diagonal-traverse) (code)
503.下一个更大元素 II(next-greater-element-ii) (code)
513.找树左下角的值(find-bottom-left-tree-value) (code)
523.连续的子数组和(continuous-subarray-sum) (code)
525.连续数组(contiguous-array) (code)
529.扫雷游戏(minesweeper) (code)
531.孤独像素 I(lonely-pixel-i) (code)
539.最小时间差(minimum-time-difference) (code)
540.有序数组中的单一元素(single-element-in-a-sorted-array) (code)
542.01 矩阵(01-matrix) (code)
547.朋友圈(friend-circles) (code)
556.下一个更大元素 III(next-greater-element-iii) (code)
560.和为K的子数组(subarray-sum-equals-k/) (code)
567.字符串的排列(permutation-in-string/) (code)
583.两个字符串的删除操作(delete-operation-for-two-strings/) (code)
611.有效三角形的个数(valid-triangle-number) (code)
638.大礼包(shopping-offers) (code)
647.回文子串(palindromic-substrings) (code)
648.单词替换(replace-words) (code)
650.只有两个键的键盘(2-keys-keyboard) (code)
654.最大二叉树(maximum-binary-tree) (code)
659.分割数组为连续子序列(split-array-into-consecutive-subsequences) (code)
667.优美的排列 II(beautiful-arrangement-ii) (code)
673.最长递增子序列的个数(number-of-longest-increasing-subsequence) (code)
694.不同岛屿的数量(number-of-distinct-islands) (code)
695.岛屿的最大面积(max-area-of-island) (code)
698.划分为k个相等的子集(partition-to-k-equal-sum-subsets) (code)
713.乘积小于K的子数组(subarray-product-less-than-k) (code)
718.最长重复子数组(maximum-length-of-repeated-subarray) (code)
723.粉碎糖果(candy-crush) (code)
725.分隔链表(split-linked-list-in-parts) (code)
738.单调递增的数字(monotone-increasing-digits) (code)
739.每日温度(daily-temperatures) (code)
722.删除注释(remove-comments) (code)
763.划分字母区间(partition-labels) (code)
767.重构字符串(reorganize-string) (code)
787.K 站中转内最便宜的航班(cheapest-flights-within-k-stops) (code)
792.匹配子序列的单词数(number-of-matching-subsequences) (code)
795.区间子数组个数(number-of-subarrays-with-bounded-maximum) (code)
797.所有可能的路径(all-paths-from-source-to-target) (code)
799.香槟塔(champagne-tower) (code)
807.保持城市天际线(max-increase-to-keep-city-skyline) (code)
820.单词的压缩编码(short-encoding-of-words) (code)
831.隐藏个人信息(masking-personal-information) (code)
833.字符串中的查找与替换(keys-and-rooms) (code)
841.钥匙和房间(keys-and-rooms) (code)
842.将数组拆分成斐波那契序列(split-array-into-fibonacci-sequence) (code)
845.数组中的最长山脉(longest-mountain-in-array) (code)
846.一手顺子(hand-of-straights) (code)
848.字母移位(shifting-letters) (code)
856.括号的分数(score-of-parentheses) (code)
881.救生艇(boats-to-save-people) (code)
889.根据前序和后序遍历构造二叉树(shifting-letters) (code)
912.排序数组(sort-an-array) (code)
916.单词子集(word-subsets) (code)
921.使括号有效的最少添加(minimum-add-to-make-parentheses-valid) (code)
930.和相同的二元子数组(binary-subarrays-with-sum) (code)
935.骑士拨号器(knight-dialer) (code)
939.最小面积矩形(minimum-area-rectangle) (code)
945.使数组唯一的最小增量(minimum-increment-to-make-array-unique) (code)
946.验证栈序列(validate-stack-sequences) (code)
950.按递增顺序显示卡牌(reveal-cards-in-increasing-order) (code)
962.最大宽度坡(maximum-width-ramp) (code)
967.连续差相同的数字(numbers-with-same-consecutive-differences) (code)
969.煎饼排序(pancake-sorting) (code)
973.最接近原点的 K 个点(k-closest-points-to-origin) (code)
984.不含 AAA 或 BBB 的字符串(string-without-aaa-or-bbb) (code)
990.等式方程的可满足性(satisfiability-of-equality-equations) (code)
991.坏了的计算器(broken-calculator) (code)
994.腐烂的橘子(rotting-oranges) (code)
1008.先序遍历构造二叉树(construct-binary-search-tree-from-preorder-traversal) (code)
1060.有序数组中的缺失元素(missing-element-in-sorted-array) (code)
1101.彼此熟识的最早时间(the-earliest-moment-when-everyone-become-friends) (code)
1017.负二进制转换(convert-to-base-2) (code)
1120.子树的最大平均值(maximum-average-subtree) (code)
1130.叶值的最小代价生成树(minimum-cost-tree-from-leaf-values) (code)
1135.最低成本联通所有城市(connecting-cities-with-minimum-cost) (code)

Difficult

123.买卖股票的最佳时机 III(best-time-to-buy-and-sell-stock-iii) (code)
440.字典序的第K小数字(k-th-smallest-in-lexicographical-order) (code)
1121.将数组分成几个递增序列(divide-array-into-increasing-sequences) (code)
1136.平行课程(parallel-courses) (code)

About

leetcode刷题笔记 python代码实现


Languages

Language:Python 94.6%Language:Java 5.4%