Leetcode 解题记录。根据题目的场景/标签归档,并以此位单位归纳总结。
- 题号:四位数字方便搜索定位。
- 总结:当前标签/主题相关的理论知识及解题套路和心得总结
- 地址:包括leetcode.com 和 leetcode-cn.com
- 难度:作者对题目难度的定义,会在官方给定难度等级之上通过
+
,-
进行标记 - 代码:
Java
解法的代码,一般会包含最符合题意的解及效率最高解。并给出每种解的提交数据反馈。 - 结果:最优解的提交反馈数据
- 标签:相关标签,一般是最优或者最直观解法使用的算法思想
目前正在探索使用Obisidian整理题解,逐渐提供比代码本身更有信息量的内容。
README 文件通过此类生成。
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0031 | next-permutation | next-permutation | Medium | java | 100% 66% | Greedy |
0039 | combination-sum | combination-sum | Medium | java | 77.47% 86.63% | combination |
0040 | combination-sum-ii | combination-sum-ii | Medium | java | 40.55% 53.43% | combination |
0046 | permutations | permutations | Medium | java | 96.75% 5.14% | Backtracking |
0047 | permutations-ii | permutations-ii | Medium | java | 100.00% 17.50% | Backtracking |
0077 | combinations | combinations | Medium | java | 93.17% 74.09% | Backtracking |
0078 | subsets | subsets | Medium | java | 82.14% 5.24% | combination |
0090 | subsets-ii | subsets-ii | Medium | java | 100.00% 24.48% | combination |
lcof38 | zi-fu-chuan-de-pai-lie-lcof | zi-fu-chuan-de-pai-lie-lcof | Medium | java | 99.28% 49.61% | Backtracking |
0060 | permutation-sequence | permutation-sequence | Hard | java | 57.64% 43.94% | Math |
0216 | combination-sum-iii | combination-sum-iii | Medium | java | 46.43% 42.73% | Backtracking |
0377 | combination-sum-iv | combination-sum-iv | Medium- | java | 99.56% 51.40% | DP |
0567 | permutation-in-string | permutation-in-string | Medium | java | 58.10% 18.75% | Sliding Window |
0784 | letter-case-permutation | letter-case-permutation | Easy | java | 100.00% 99.36% | Backtracking |
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
mst01.08 | zero-matrix-lcci | zero-matrix-lcci | Medium- | java | 50% 50% | Matrix |
0054 | spiral-matrix | spiral-matrix | Medium | java | 100.00% 99.54% | Matrix |
0200 | number-of-islands | number-of-islands | Medium | java | 91.40% 15.30% | dfs |
0240 | search-a-2d-matrix-ii | search-a-2d-matrix-ii | Medium | java | 97.85% 17.32% | Matrix |
0289 | game-of-life | game-of-life | Medium | java | 100.00% 91.85% | Matrix |
0695 | max-area-of-island | max-area-of-island | Medium | java | 82.11% 91.14% | Matrix, Back tracking |
0766 | toeplitz-matrix | toeplitz-matrix | Easy | java | 100.00% 73.60% | Matrix |
0832 | flipping-an-image | flipping-an-image | null | java | 100.00% 99.95% | Matrix |
0867 | transpose-matri | transpose-matri | Easy- | java | 100.00% 99.81% | Matrix |
0985 | reshape-the-matrix | reshape-the-matrix | Easy- | java | 100.00% 100.00% | Matrix |
0999 | available-captures-for-rook | available-captures-for-rook | Easy | java | 100.00% 99.95% | Matrix |
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0219 | contains-duplicate-ii | contains-duplicate-ii | Easy- | java | 95.81% 5.72% | Hashtable |
0242 | valid-anagram | valid-anagram | null | java | 90.46% 71.14% | Hashtable |
0389 | find-the-difference | find-the-difference | Easy | java | 99.37% 19.48% | Hashtable |
0409 | longest-palindrome | longest-palindrome | Easy | java | 100.00% 100% | Hashtable |
0454 | 4sum-ii | 4sum-ii | medium | java | 99.35% 53.32% | Two Pointers |
0594 | longest-harmonious-subsequence | longest-harmonious-subsequence | Easy+ | java | 100.00% 13.99% | Hashtable |
0692 | top-k-frequent-words | top-k-frequent-words | null | java | 99.50% 89.29% | Hashtable |
1160 | find-words-that-can-be-formed-by-characters | find-words-that-can-be-formed-by-characters | Easy | java | 84.18% 5.08% | Hashtable |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0008 | string-to-integer-atoi | string-to-integer-atoi | Medium | java | 99.87% 93.46% | String |
0014 | longest-common-prefix | longest-common-prefix | Easy- | java | 74.35% 100% | String |
0038 | count-and-say | count-and-say | Easy | java | 100 % 100 % | String |
0058 | length-of-last-word | length-of-last-word | Easy | java | 100.00% 5.32% | String |
0067 | add-binary | add-binary | Easy | java | 97.15% 5.12% | String |
0205 | isomorphic-strings | isomorphic-strings | Easy- | java | 81.95% 34.68% | String |
0344 | reverse-string | reverse-string | Easy- | java | 100.00% 18.74% | String |
0415 | add-strings | add-strings | Easy | java | 99.62% 26.75% | Math |
0541 | reverse-string-ii | reverse-string-ii | Easy | java | 100.00% 25.50% | String |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0005 | longest-palindromic-substring | longest-palindromic-substring | Medium | java | 87.40% 69.11% | String |
0009 | palindrome-number | palindrome-number | Easy | java | 100.00% 5.02% | Math |
0125 | valid-palindrome | valid-palindrome | Easy | java | 100% 100% | String |
0234 | palindrome-linked-list | palindrome-linked-list | Easy+ | java | 99.87% 7.54% | findpattern.palindromic |
0516 | longest-palindromic-subsequence | longest-palindromic-subsequence | Medium | java | 100% 100% | Dynamic Programming |
0647 | palindromic-substrings | palindromic-substrings | Medium | java | 99.97% 100.00% | Dynamic Programming |
0680 | valid-palindrome-ii | valid-palindrome-ii | Easy | java | 99.68% 94.44% | String |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0102 | binary-tree-level-order-traversal | binary-tree-level-order-traversal | Medium | java | 99.79% 5.13% | Breadth First Search |
0103 | binary-tree-zigzag-level-order-traversal | binary-tree-zigzag-level-order-traversal | Medium- | java | 98.10% 34.57% | Breadth First Search |
0107 | binary-tree-level-order-traversal-ii | binary-tree-level-order-traversal-ii | Easy | java | 99.79% 5.13% | Breadth First Search |
0111 | minimum-depth-of-binary-tree | minimum-depth-of-binary-tree | Easy | java | 100.00% 5.33% | Breadth First Search |
0199 | binary-tree-right-side-view | binary-tree-right-side-view | Medium- | java | 95.83% 16.21% | Breadth First Search |
0637 | average-of-levels-in-binary-tree | average-of-levels-in-binary-tree | null | java | 99.18% 24.76% | Breadth First Search |
0752 | open-the-lock | open-the-lock | Medium | java | 100% 83.33% | Breadth First Search |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0136 | single-number | single-number | Easy | java | 100% 100% | Bit Manipulation |
0137 | single-number-ii | single-number-ii | Medium | java | 100% 100% | Bit Manipulation |
0190 | reverse-bits | reverse-bits | Easy | java | 100.00% 92.12% | Bit Manipulation |
0191 | number-of-1-bits | number-of-1-bits | Easy | java | 100% 100% | Bit Manipulation |
0260 | single-number-iii | single-number-iii | Medium | java | 100% 16.67% | Bit Manipulation |
0371 | sum-of-two-integers | sum-of-two-integers | Easy | java | 100% 8.00% | Bit Manipulation |
0397 | integer-replacement | integer-replacement | Medium | java | 100% 8.00% | Bit Manipulation |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0017 | letter-combinations-of-a-phone-number | letter-combinations-of-a-phone-number | Medium | java | 100.00% 84.17% | Backtracking |
0037 | sudoku-solver | sudoku-solver | Hard | java | 97.00% 94.25% | Backtracking |
0051 | n-queens | n-queens | Hard- | java | 100% 100% | Backtracking |
0079 | word-search | word-search | Medium | java | 99.91% 100.00% | Backtracking |
0212 | word-search-ii | word-search-ii | Hard | java | 99.98% 77.78% | Backtracking |
0679 | 24-game | 24-game | Hard | java | 93.33% 14.29% | Backtracking |
0784 | letter-case-permutation | letter-case-permutation | Easy | java | 89.19% 100.00% | Backtracking |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0139 | word-break | word-break | Medium | java | 99.62% 77.20% | tree.trie |
0140 | word-break-ii | word-break-ii | Hard | java | 100.00% 92.20% | tree.trie |
0208 | implement-trie-prefix-tree | implement-trie-prefix-tree | Medium- | java | 99.79% 98.24% | Trie |
0211 | design-add-and-search-words-data-structure | design-add-and-search-words-data-structure | Medium | java | 100.00% 76.32% | Trie |
0720 | longest-word-in-dictionary | longest-word-in-dictionary | Easy | java | 100.00% 97.61% | Trie |
1023 | camelcase-matching | camelcase-matching | Medium | java | 100.00% 99.58% | Trie |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
mst01.05 | one-away-lcci | one-away-lcci | Medium | java | 100.00% 5.04% | Find Pattern |
0005 | longest-palindromic-substring | longest-palindromic-substring | Medium | java | 87.40% 69.11% | String |
0006 | zigzag-conversion | zigzag-conversion | Medium | java | 99.87% 93.46% | String |
0009 | palindrome-number | palindrome-number | Easy | java | 100.00% 5.02% | Math |
0022 | generate-parentheses | generate-parentheses | Medium | java | 100.00% 68.18% | Backtracking |
0048 | rotate-image | rotate-image | Medium | java | 100% 100% | Find Pattern |
0055 | jump-game | jump-game | Medium | java | 100% 5.09% | Dynamic Programming |
0125 | valid-palindrome | valid-palindrome | Easy | java | 100% 100% | String |
0234 | palindrome-linked-list | palindrome-linked-list | Easy+ | java | 99.87% 7.54% | findpattern.palindromic |
0516 | longest-palindromic-subsequence | longest-palindromic-subsequence | Medium | java | 100% 100% | Dynamic Programming |
0647 | palindromic-substrings | palindromic-substrings | Medium | java | 99.97% 100.00% | Dynamic Programming |
0680 | valid-palindrome-ii | valid-palindrome-ii | Easy | java | 99.68% 94.44% | String |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0112 | path-sum | path-sum | Easy | java | 100.00% 6.52% | Depth-First Search |
0113 | path-sum-ii | path-sum-ii | Medium | java | 65.46% 5.26% | Depth-First Search |
0113 | path-sum-ii | path-sum-ii | Hard | java | 99.67% 1ms 7.69% | Depth-First Search |
0129 | sum-root-to-leaf-numbers | sum-root-to-leaf-numbers | Medium | java | 100.00% 87.92% | Depth-First Search |
0257 | binary-tree-paths | binary-tree-paths | Easy | java | 93.46% 37.08% | Depth-First Search |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0012 | integer-to-roman | integer-to-roman | Medium- | java | 100.00% 100.00% | Greedy |
0013 | roman-to-integer | roman-to-integer | Easy | java | 94.96% 94.49% | Math |
0053 | maximum-subarray | maximum-subarray | Easy | java | 100.00% 99.53% | Greedy, DP |
0392 | is-subsequence | is-subsequence | Easy | java | 100.00% 100.00% | Greedy |
0751 | ip-to-cidr | ip-to-cidr | Easy+ | java | 100.00% 100.00% | Greedy |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0292 | nim-game | nim-game | Easy | java | 100.00% 100.00% | Minimax |
0375 | guess-number-higher-or-lower-ii | guess-number-higher-or-lower-ii | Medium | java | 99.47% 5.41% | Minimax |
0486 | predict-the-winner | predict-the-winner | Medium | java | 100.00% 5.45% | Minimax |
0877 | stone-game | stone-game | Medium | java | 100.00% 100.00% | Minimax |
1140 | stone-game-ii | stone-game-ii | Medium | java | 100.00% 100.00% | Minimax |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0028 | implement-strstr | implement-strstr | Easy+ | java | 53.86% 64.88% | String |
0030 | substring-with-concatenation-of-all-words | substring-with-concatenation-of-all-words | Hard | java | 47.38% 5.00% | String Match |
0758 | bold-words-in-string | bold-words-in-string | Easy + | java | 96.18% 100.00% | String Match |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0220 | contains-duplicate-iii | contains-duplicate-iii | Medium | java | 90.80% 5.28% | Ordered Map |
0352 | data-stream-as-disjoint-intervals | data-stream-as-disjoint-intervals | Hard | java | 75.24% 75.00% | Ordered Map |
0729 | my-calendar-i | my-calendar-i | Medium | java | 55.27% 19.51% | Ordered Map |
0731 | my-calendar-ii | my-calendar-ii | Medium+ | java | 100.00% 70.83% | Ordered Map |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0003 | longest-substring-without-repeating-characters | longest-substring-without-repeating-characters | Medium | java | 99.83% 80.19% | Sliding Window |
0076 | minimum-window-substring | minimum-window-substring | Hard | java | 42.34% 13.33% | Sliding Window |
0239 | sliding-window-maximum | sliding-window-maximum | Hard | java | 39.53% 6.67% | Sliding Window |
0424 | longest-repeating-character-replacement | longest-repeating-character-replacement | Medium | java | 33.67% 100.00% | Sliding Window |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0892 | surface-area-of-3d-shapes | surface-area-of-3d-shapes | Easy | java | 77.35% 100.00% | Math |
0963 | minimum-area-rectangle-ii | minimum-area-rectangle-ii | Medium+ | java | 52.63% 100.00% | Geometry |
1401 | circle-and-rectangle-overlapping | circle-and-rectangle-overlapping | Medium | java | 100.00% 100.00% | Geometry |
总结调整中,草稿内容请参考这里
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
Offer20 | biao-shi-shu-zhi-de-zi-fu-chuan-lcof | biao-shi-shu-zhi-de-zi-fu-chuan-lcof | Medium | java | 66.54% 58.76% | Math |
0146 | lru-cache | lru-cache | Medium | java | 91.27% 67.29% | Design |
Offer09 | yong-liang-ge-zhan-shi-xian-dui-lie-lcof | yong-liang-ge-zhan-shi-xian-dui-lie-lcof | Easy | java | 69.99% 40.92% | Queue, Stack |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0151 | reverse-words-in-a-string | reverse-words-in-a-string | Easy | java | 100.00% 16.01% | Pure Programming |
1360 | number-of-days-between-two-dates | number-of-days-between-two-dates | Easy | java | 100% 100% | Details |
mst16.04 | tic-tac-toe-lcci | tic-tac-toe-lcci | Medium | java | 75.80% 5.19% | Pure Programming |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0114 | flatten-binary-tree-to-linked-list | flatten-binary-tree-to-linked-list | Medium | java | 100% 99.89% | Morris Traversal |
0501 | find-mode-in-binary-search-tree | find-mode-in-binary-search-tree | Easy | java | 100% 100% | Morris Traversal |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0021 | merge-two-sorted-lists | merge-two-sorted-lists | Easy | java | 100.00% 79.05% | Linked List, Recursion |
0023 | merge-k-sorted-lists | merge-k-sorted-lists | Hard | java | 84.07% 48.81% | Divide & Conquer |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0547 | friend-circles | friend-circles | Medium | java | 99.93% 96.00% | Union Find |
0990 | satisfiability-of-equality-equations | satisfiability-of-equality-equations | Medium | java | 100.00% 16.67% | Union Find |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0215 | kth-largest-element-in-an-array | kth-largest-element-in-an-array | Medium | java | 99.87% 5.15% | Divide & Conquer, Heap |
0241 | different-ways-to-add-parentheses | different-ways-to-add-parentheses | Medium | java | 100% 100% | Divide & Conquer |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
1114 | print-in-order | print-in-order | Easy | java | 100% 100% | Concurrency |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0019 | remove-nth-node-from-end-of-list | remove-nth-node-from-end-of-list | Medium- | java | 100.00% 94.24% | Two Pointers |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0939 | minimum-area-rectangle | minimum-area-rectangle | Medium | java | 77.35% 100.00% | Hash Function |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0997 | find-the-town-judge | find-the-town-judge | null | java | 98.73% 100.00% | Graph |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
1071 | greatest-common-divisor-of-strings | greatest-common-divisor-of-strings | Easy | java | 97.81% 100.00% | Greatest Common Divisor |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|---|---|---|---|---|---|
0703 | kth-largest-element-in-a-stream | kth-largest-element-in-a-stream | null | java | 99.55% 64.02% | Heap |
总结调整中,草稿内容请参考这里
题号 | 题目(官网) | 题目(中国) | 难度 | 代码 | 结果 | 标签 |
---|