LCTM Thanks leetcode 经典题目的解析 LeetCode 刷题攻略 算法模板 Summary Go Python Rust Java EASY 69 78 2 5 MEDIUM 75 98 1 4 HARD 6 7 0 0 TOTAL 150 183 3 9 Problems # Title Solutions Difficulty 1 Two Sum 两数之和 Go Java Python Rust EASY 2 Add Two Numbers 两数相加 Go Java Python MEDIUM 3 Longest Substring Without Repeating Characters 无重复字符的最长子串 Go Java Python Rust MEDIUM 5 Longest Palindromic Substring 最长回文子串 Go Python MEDIUM 7 Reverse Integer 整数反转 Go Java Python EASY 14 Longest Common Prefix 最长公共前缀 Go Python EASY 15 3Sum 三数之和 Go Java Python MEDIUM 17 Letter Combinations of a Phone Number 电话号码的字母组合 Go Python MEDIUM 18 4Sum 四数之和 Go Python MEDIUM 19 Remove Nth Node From End of List 删除链表的倒数第 N 个结点 Go Java Python MEDIUM 20 Valid Parentheses 有效的括号 Go Python Rust EASY 21 Merge Two Sorted Lists 合并两个有序链表 Go Python EASY 22 Generate Parentheses 括号生成 Python MEDIUM 24 Swap Nodes in Pairs 两两交换链表中的节点 Go Python MEDIUM 26 Remove Duplicates from Sorted Array 删除有序数组中的重复项 Go Python EASY 27 Remove Element 移除元素 Go Python EASY 28 Implement strStr() 实现 strStr() Go Python EASY 29 Divide Two Integers 两数相除 Python MEDIUM 34 Find First and Last Position of Element in Sorted Array 在排序数组中查找元素的第一个和最后一个位置 Python MEDIUM 35 Search Insert Position 搜索插入位置 Go Python EASY 39 Combination Sum 组合总和 Go Python MEDIUM 40 Combination Sum II 组合总和 II Go Python MEDIUM 41 First Missing Positive 缺失的第一个正数 Python HARD 42 Trapping Rain Water 接雨水 Go Python HARD 45 Jump Game II 跳跃游戏 II Go Python MEDIUM 46 Permutations 全排列 Go Python MEDIUM 47 Permutations II 全排列 II Go Python MEDIUM 50 Pow(x, n) Pow(x, n) Python MEDIUM 53 Maximum Subarray 最大子序和 Go Python EASY 55 Jump Game 跳跃游戏 Go Python MEDIUM 56 Merge Intervals 合并区间 Go Python MEDIUM 59 Spiral Matrix II 螺旋矩阵 II Go Python MEDIUM 61 Rotate List 旋转链表 Go Python MEDIUM 62 Unique Paths 不同路径 Go Python MEDIUM 63 Unique Paths II 不同路径 II Go Python MEDIUM 64 Minimum Path Sum 最小路径和 Python MEDIUM 66 Plus One 加一 Go Python EASY 70 Climbing Stairs 爬楼梯 Go Java Python EASY 76 Minimum Window Substring 最小覆盖子串 Python HARD 77 Combinations 组合 Go Python MEDIUM 78 Subsets 子集 Go Python MEDIUM 82 Remove Duplicates from Sorted List II 删除排序链表中的重复元素 II Go Python MEDIUM 83 Remove Duplicates from Sorted List 删除排序链表中的重复元素 Go Python EASY 84 Largest Rectangle in Histogram 柱状图中最大的矩形 Go HARD 86 Partition List 分隔链表 Go Python MEDIUM 88 Merge Sorted Array 合并两个有序数组 Go Python EASY 90 Subsets II 子集 II Go Python MEDIUM 91 Decode Ways 解码方法 Python MEDIUM 92 Reverse Linked List II 反转链表 II Go Python MEDIUM 93 Restore IP Addresses 复原 IP 地址 Go Python MEDIUM 95 Unique Binary Search Trees II 不同的二叉搜索树 II Python MEDIUM 96 Unique Binary Search Trees 不同的二叉搜索树 Go Python MEDIUM 98 Validate Binary Search Tree 验证二叉搜索树 Go Python MEDIUM 100 Same Tree 相同的树 Go Python EASY 101 Symmetric Tree 对称二叉树 Go Python EASY 102 Binary Tree Level Order Traversal 二叉树的层序遍历 Go Python MEDIUM 103 Binary Tree Zigzag Level Order Traversal 二叉树的锯齿形层序遍历 Go Python MEDIUM 104 Maximum Depth of Binary Tree 二叉树的最大深度 Go Python EASY 105 Construct Binary Tree from Preorder and Inorder Traversal 从前序与中序遍历序列构造二叉树 Go Python MEDIUM 106 Construct Binary Tree from Inorder and Postorder Traversal 从中序与后序遍历序列构造二叉树 Go Python MEDIUM 107 Binary Tree Level Order Traversal II 二叉树的层序遍历 II Go Python MEDIUM 108 Convert Sorted Array to Binary Search Tree 将有序数组转换为二叉搜索树 Go Python EASY 110 Balanced Binary Tree 平衡二叉树 Go Python EASY 111 Minimum Depth of Binary Tree 二叉树的最小深度 Go Python EASY 112 Path Sum 路径总和 Go Python EASY 113 Path Sum II 路径总和 II Go Python MEDIUM 114 Flatten Binary Tree to Linked List 二叉树展开为链表 Python MEDIUM 116 Populating Next Right Pointers in Each Node 填充每个节点的下一个右侧节点指针 Go Python MEDIUM 117 Populating Next Right Pointers in Each Node II 填充每个节点的下一个右侧节点指针 II Go Python MEDIUM 118 Pascal's Triangle 杨辉三角 Python EASY 119 Pascal's Triangle II 杨辉三角 II Python EASY 120 Triangle 三角形最小路径和 Python MEDIUM 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机 Go Python EASY 122 Best Time to Buy and Sell Stock II 买卖股票的最佳时机 II Go Python EASY 124 Binary Tree Maximum Path Sum 二叉树中的最大路径和 Go Python HARD 125 Valid Palindrome 验证回文串 Go Python EASY 128 Longest Consecutive Sequence 最长连续序列 Python MEDIUM 129 Sum Root to Leaf Numbers 求根节点到叶节点数字之和 Python MEDIUM 131 Palindrome Partitioning 分割回文串 Go Python MEDIUM 134 Gas Station 加油站 Go MEDIUM 135 Candy 分发糖果 Go HARD 136 Single Number 只出现一次的数字 Go Python EASY 139 Word Break 单词拆分 Python MEDIUM 140 Word Break II 单词拆分 II Python HARD 141 Linked List Cycle 环形链表 Go Python EASY 142 Linked List Cycle II 环形链表 II Go MEDIUM 143 Reorder List 重排链表 Python MEDIUM 144 Binary Tree Preorder Traversal 二叉树的前序遍历 Go Python EASY 145 Binary Tree Postorder Traversal 二叉树的后序遍历 Go Python EASY 146 LRU Cache LRU 缓存机制 Python MEDIUM 148 Sort List 排序链表 Go Python MEDIUM 150 Evaluate Reverse Polish Notation 逆波兰表达式求值 Go Python MEDIUM 151 Reverse Words in a String 翻转字符串里的单词 Go Python MEDIUM 152 Maximum Product Subarray 乘积最大子数组 Python MEDIUM 155 Min Stack 最小栈 Go Python EASY 167 Two Sum II - Input array is sorted 两数之和 II - 输入有序数组 Go Python EASY 169 Majority Element 多数元素 Python EASY 189 Rotate Array 旋转数组 Python MEDIUM 198 House Robber 打家劫舍 Python MEDIUM 199 Binary Tree Right Side View 二叉树的右视图 Go Python MEDIUM 200 Number of Islands 岛屿数量 Python MEDIUM 202 Happy Number 快乐数 Go Python EASY 203 Remove Linked List Elements 移除链表元素 Go Python EASY 206 Reverse Linked List 反转链表 Go Python EASY 209 Minimum Size Subarray Sum 长度最小的子数组 Go Python MEDIUM 213 House Robber II 打家劫舍 II Python MEDIUM 216 Combination Sum III 组合总和 III Go Python MEDIUM 217 Contains Duplicate 存在重复元素 Python EASY 219 Contains Duplicate II 存在重复元素 II Python EASY 221 Maximal Square 最大正方形 Python MEDIUM 222 Count Complete Tree Nodes 完全二叉树的节点个数 Go Python MEDIUM 225 Implement Stack using Queues 用队列实现栈 Go Python EASY 226 Invert Binary Tree 翻转二叉树 Go Python EASY 230 Kth Smallest Element in a BST 二叉搜索树中第K小的元素 Python MEDIUM 232 Implement Queue using Stacks 用栈实现队列 Go Python EASY 234 Palindrome Linked List 回文链表 Go Python EASY 235 Lowest Common Ancestor of a Binary Search Tree 二叉搜索树的最近公共祖先 Go Python EASY 236 Lowest Common Ancestor of a Binary Tree 二叉树的最近公共祖先 Go Python MEDIUM 237 Delete Node in a Linked List 删除链表中的节点 Go Python EASY 239 Sliding Window Maximum 滑动窗口最大值 Go HARD 242 Valid Anagram 有效的字母异位词 Go Python EASY 257 Binary Tree Paths 二叉树的所有路径 Go Python EASY 263 Ugly Number 丑数 Go Python EASY 279 Perfect Squares 完全平方数 Python MEDIUM 283 Move Zeroes 移动零 Go Python EASY 300 Longest Increasing Subsequence 最长递增子序列 Go Python MEDIUM 322 Coin Change 零钱兑换 Python MEDIUM 328 Odd Even Linked List 奇偶链表 Python MEDIUM 343 Integer Break 整数拆分 Go Python MEDIUM 344 Reverse String 反转字符串 Go Python EASY 345 Reverse Vowels of a String 反转字符串中的元音字母 Python EASY 347 Top K Frequent Elements 前 K 个高频元素 Go Python MEDIUM 349 Intersection of Two Arrays 两个数组的交集 Go Python EASY 350 Intersection of Two Arrays II 两个数组的交集 II Python EASY 376 Wiggle Subsequence 摆动序列 Go Python MEDIUM 383 Ransom Note 赎金信 Go Python EASY 389 Find the Difference 找不同 Python EASY 392 Is Subsequence 判断子序列 Go EASY 404 Sum of Left Leaves 左叶子之和 Go Python EASY 406 Queue Reconstruction by Height 根据身高重建队列 Go MEDIUM 414 Third Maximum Number 第三大的数 Python EASY 429 N-ary Tree Level Order Traversal N 叉树的层序遍历 Go Python MEDIUM 435 Non-overlapping Intervals 无重叠区间 Go MEDIUM 437 Path Sum III 路径总和 III Python MEDIUM 450 Delete Node in a BST 删除二叉搜索树中的节点 Go MEDIUM 452 Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球 Go MEDIUM 454 4Sum II 四数相加 II Go MEDIUM 455 Assign Cookies 分发饼干 Go Python EASY 459 Repeated Substring Pattern 重复的子字符串 Go EASY 460 LFU Cache LFU 缓存 Python HARD 463 Island Perimeter 岛屿的周长 Python EASY 491 Increasing Subsequences 递增子序列 Go Python MEDIUM 496 Next Greater Element I 下一个更大元素 I Go Python EASY 501 Find Mode in Binary Search Tree 二叉搜索树中的众数 Go Python EASY 503 Next Greater Element II 下一个更大元素 II Go Python MEDIUM 509 Fibonacci Number 斐波那契数 Go Python EASY 513 Find Bottom Left Tree Value 找树左下角的值 Go Python MEDIUM 515 Find Largest Value in Each Tree Row 在每个树行中找最大值 Go Python MEDIUM 516 Longest Palindromic Subsequence 最长回文子序列 Go Python MEDIUM 518 Coin Change 2 零钱兑换 II Python MEDIUM 530 Minimum Absolute Difference in BST 二叉搜索树的最小绝对差 Go EASY 538 Convert BST to Greater Tree 把二叉搜索树转换为累加树 Go Python MEDIUM 541 Reverse String II 反转字符串 II Go EASY 543 Diameter of Binary Tree 二叉树的直径 Go EASY 559 Maximum Depth of N-ary Tree N 叉树的最大深度 Go Python EASY 563 Binary Tree Tilt 二叉树的坡度 Python EASY 567 Permutation in String 字符串的排列 Python MEDIUM 572 Subtree of Another Tree 另一棵树的子树 Python EASY 575 Distribute Candies 分糖果 Python EASY 583 Delete Operation for Two Strings 两个字符串的删除操作 Go Python MEDIUM 617 Merge Two Binary Trees 合并二叉树 Go Python EASY 637 Average of Levels in Binary Tree 二叉树的层平均值 Go Python EASY 639 Decode Ways II 解码方法 II Python HARD 647 Palindromic Substrings 回文子串 Go Python MEDIUM 654 Maximum Binary Tree 最大二叉树 Go Python MEDIUM 669 Trim a Binary Search Tree 修剪二叉搜索树 Go Python MEDIUM 674 Longest Continuous Increasing Subsequence 最长连续递增序列 Go EASY 695 Max Area of Island 岛屿的最大面积 Python MEDIUM 700 Search in a Binary Search Tree 二叉搜索树中的搜索 Go Python EASY 701 Insert into a Binary Search Tree 二叉搜索树中的插入操作 Go Python MEDIUM 704 Binary Search 二分查找 Go Python EASY 706 Design HashMap 设计哈希映射 Python EASY 714 Best Time to Buy and Sell Stock with Transaction Fee 买卖股票的最佳时机含手续费 Go Python MEDIUM 718 Maximum Length of Repeated Subarray 最长重复子数组 Go Python MEDIUM 738 Monotone Increasing Digits 单调递增的数字 Go MEDIUM 739 Daily Temperatures 每日温度 Go Python MEDIUM 746 Min Cost Climbing Stairs 使用最小花费爬楼梯 Go Python EASY 763 Partition Labels 划分字母区间 Go MEDIUM 814 Binary Tree Pruning 二叉树剪枝 Python MEDIUM 821 Shortest Distance to a Character 字符的最短距离 Python EASY 860 Lemonade Change 柠檬水找零 Go EASY 912 Sort an Array 排序数组 Python MEDIUM 941 Valid Mountain Array 有效的山脉数组 Go Python EASY 968 Binary Tree Cameras 监控二叉树 Go HARD 1005 Maximize Sum Of Array After K Negations K 次取反后最大化的数组和 Go Python EASY 1015 Smallest Integer Divisible by K 可被 K 整除的最小整数 Python MEDIUM 1019 Next Greater Node In Linked List 链表中的下一个更大节点 Python MEDIUM 1022 Sum of Root To Leaf Binary Numbers 从根到叶的二进制数之和 Python EASY 1035 Uncrossed Lines 不相交的线 Go MEDIUM 1047 Remove All Adjacent Duplicates In String 删除字符串中的所有相邻重复项 Go Python EASY 1137 N-th Tribonacci Number 第 N 个泰波那契数 Java Python EASY 1143 Longest Common Subsequence 最长公共子序列 Go Python MEDIUM 1207 Unique Number of Occurrences 独一无二的出现次数 Go EASY 1365 How Many Numbers Are Smaller Than the Current Number 有多少小于当前数字的数字 Go Java Python EASY 1438 Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit 绝对差不超过限制的最长连续子数组 Python MEDIUM