## My solutions to Leetcode
I will put my solutions to [Leetcode Problems](https://leetcode.com/problemset/all/) in this repo. Every problem will be solved in C++; part of the problems will be solved in Java also. I will try my best to support more language in the future :)
Please feel free to contact me if you have any questions with this repo:)
email: [
[email protected]](mailto:
[email protected])
---
大家好,欢迎大家来到我的 **Leetcode 算法题解**代码仓。在这个代码仓中,近乎每一个问题都会使用多种方式进行解决,同时标注了简明的算法思想,时间复杂度和空间复杂度。所有问题都会使用C++进行解决,各别问题支持Java语言和Python语言。
如果对代码仓有任何问题,欢迎联系我:)
**电子邮件**:[
[email protected]](mailto:
[email protected])
**知乎**: [刘宇波 http://www.zhihu.com/people/liuyubobobo](http://www.zhihu.com/people/liuyubobobo)
**知乎专栏:**[是不是很酷 https://zhuanlan.zhihu.com/liuyubobobo](https://zhuanlan.zhihu.com/liuyubobobo)
**个人公众号:是不是很酷**:)
**知识星球(免费)**
## 其他相关代码仓
* [**《算法与数据结构》课程**](https://coding.imooc.com/class/71.html), 代码仓: [Play-with-Algorithms](https://github.com/liuyubobobo/Play-with-Algorithms)
* [**《玩转算法面试》课程**](https://coding.imooc.com/class/82.html), 代码仓: [Play-with-Algorithm-Interview](https://github.com/liuyubobobo/Play-with-Algorithm-Interview)
* [**《看得见的算法》课程**](https://coding.imooc.com/class/138.html), 代码仓: [Play-with-Algorithm-Visualization](https://github.com/liuyubobobo/Play-with-Algorithm-Visualization)
* [**《玩转数据结构》课程**](https://coding.imooc.com/class/207.html), 代码仓: [Play-with-Data-Structures](https://github.com/liuyubobobo/Play-with-Data-Structures)
* [**《玩转图论算法》课程**](https://coding.imooc.com/class/370.html), 代码仓: [Play-with-Graph-Algorithms](https://github.com/liuyubobobo/Play-with-Graph-Algorithms)
* **LeetCode Database 题解代码仓**:[Play Leetcode Database](https://github.com/liuyubobobo/Play-Leetcode-Database/)
## Problems
| ID | Problem | Official
Solution | C++ | Java | Python |
| --- | --- | :---: | :---: | :---: | :---: |
| 001 | [Two Sum](https://leetcode.com/problems/two-sum/description/) | [solution](https://leetcode.com/problems/two-sum/solution/) | [C++](0001-0500/0001-Two-Sum/cpp-0001/) | [Java](0001-0500/0001-Two-Sum/java-0001/src/) | |
| 002 | [Add Two Numbers](https://leetcode.com/problems/add-two-numbers/description/) | [solution](https://leetcode.com/problems/add-two-numbers/solution/) | [C++](0001-0500/0002-Add-Two-Numbers/cpp-0002/) | | |
| 003 | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/description/) | [solution](https://leetcode.com/problems/longest-substring-without-repeating-characters/solution/) | [C++](0001-0500/0003-Longest-Substring-Without-Repeating-Characters/cpp-0003/) | [Java](0001-0500/0003-Longest-Substring-Without-Repeating-Characters/java-0003/src/) | |
| 004 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/) | [solution](https://leetcode.com/problems/median-of-two-sorted-arrays/solution/) | [C++](0001-0500/0004-Median-of-Two-Sorted-Arrays/cpp-0004/) | [Java](0001-0500/0004-Median-of-Two-Sorted-Arrays/java-0004/) | |
| 005 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/) | [solution](https://leetcode.com/problems/longest-palindromic-substring/solution/) | [C++](0001-0500/0005-Longest-Palindromic-Substring/cpp-0005/) | | |
| 006 | [Zigzag Conversion](https://leetcode.com/problems/zigzag-conversion/) | [solution](https://leetcode.com/problems/zigzag-conversion/solution/) | [C++](0001-0500/0006-Zigzag-Conversion/cpp-006/) | | |
| 007 | [Reverse Integer](https://leetcode.com/problems/reverse-integer/description/) | [solution](https://leetcode.com/problems/reverse-integer/solution/) | [C++](0001-0500/0007-Reverse-Integer/cpp-0007/) | | |
| 008 | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/) | [solution](https://leetcode.com/problems/string-to-integer-atoi/solution/) | [C++](0001-0500/0008-String-to-Integer/cpp-0008/) | | |
| | | | | | |
| 010 | [Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching/) | [solution](https://leetcode.com/problems/regular-expression-matching/solution/) | [C++](0001-0500/0010-Regular-Expression-Matching/cpp-0010/) | | |
| 011 | [Container With Most Water](https://leetcode.com/problems/container-with-most-water/description/) | [solution](https://leetcode.com/problems/container-with-most-water/solution/) | [C++](0001-0500/0011-Container-With-Most-Water/cpp-0011/) | | |
| 012 | [Integer to Roman](https://leetcode.com/problems/integer-to-roman/description/) | [无] | [C++](0001-0500/0012-Integer-to-Roman/cpp-0012/) | | |
| 013 | [Roman to Integer](https://leetcode.com/problems/roman-to-integer/description/) | [无] | [C++](0001-0500/0013-Roman-to-Integer/cpp-0013/) | | |
| 014 | [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/description/) | [无] | [C++](0001-0500/0014-Longest-Common-Prefix/cpp-0014/) | | |
| 015 | [3Sum](https://leetcode.com/problems/3sum/description/) | [无] | [C++](0001-0500/0015-3Sum/cpp-0015/) | | |
| 016 | [3Sum Closest](https://leetcode.com/problems/3sum-closest/description/) | [无] | [C++](0001-0500/0016-3Sum-Closest/cpp-0016/) | | |
| 017 | [Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/) | [solution](https://leetcode.com/problems/letter-combinations-of-a-phone-number/solution/) | [C++](0001-0500/0017-Letter-Combinations-of-a-Phone-Number/cpp-0017/) | [Java](0001-0500/0017-Letter-Combinations-of-a-Phone-Number/java-0017/src/) | |
| 018 | [4Sum](https://leetcode.com/problems/4sum/description/) | [无] | [C++](0001-0500/0018-4Sum/cpp-0018/) | | |
| 019 | [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/) | [solution](https://leetcode.com/problems/remove-nth-node-from-end-of-list/solution/) | [C++](0001-0500/0019-Remove-Nth-Node-From-End-of-List/cpp-0019/) | [Java](0001-0500/0019-Remove-Nth-Node-From-End-of-List/java-0019/src/) | |
| 020 | [Valid Parentheses](https://leetcode.com/problems/valid-parentheses/description/) | [solution](https://leetcode.com/problems/valid-parentheses/solution/) | [C++](0001-0500/0020-Valid-Parentheses/cpp-0020/) | [Java](0001-0500/0020-Valid-Parentheses/java-0020/src/) | |
| 021 | [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists/description/) | [solution](https://leetcode.com/problems/merge-two-sorted-lists/solution/) | [C++](0001-0500/0021-Merge-Two-Sorted-Lists/cpp-0021/) | | |
| 022 | [Generate Parentheses](https://leetcode.com/problems/generate-parentheses/description/) | [solution](https://leetcode.com/problems/generate-parentheses/solution/) | [C++](0001-0500/0022-Generate-Parentheses/cpp-0022/) | [Java](0001-0500/0022-Generate-Parentheses/java-0022/) | [Python](0022-Generate-Parentheses/py-0022/) |
| 023 | [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/description/) | [solution](https://leetcode.com/problems/merge-k-sorted-lists/solution/) | [C++](0001-0500/0023-Merge-k-Sorted-Lists/cpp-0023/) | | |
| 024 | [Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs/description/) | [无] | [C++](0001-0500/0024-Swap-Nodes-in-Pairs/cpp-0024/) | [Java](0001-0500/0024-Swap-Nodes-in-Pairs/java-0024/src/) | |
| 025 | [Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group/description/) | [无] | [C++](0001-0500/0025-Reverse-Nodes-in-k-Group/cpp-0025/) | | |
| 026 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/) | [solution](https://leetcode.com/problems/remove-duplicates-from-sorted-array/solution/) | [C++](0001-0500/0026-Remove-Duplicates-from-Sorted-Array/cpp-0026/) | | |
| 027 | [Remove Element](https://leetcode.com/problems/remove-element/description/) | [solution](https://leetcode.com/problems/remove-element/solution/) | [C++](0001-0500/0027-Remove-Element/cpp-0027/) | | |
| 028 | [Implement strStr()](https://leetcode.com/problems/implement-strstr/description/) | [无]
[缺:完整BM算法, 其他模式匹配算法] | [C++](0001-0500/0028-Implement-strStr/cpp-0028/) | | |
| 029 | [Divide Two Integers](https://leetcode.com/problems/divide-two-integers/) | [solution](https://leetcode.com/problems/divide-two-integers/solution/)
[缺:不使用乘法加法除法] | [C++](0001-0500/0029-Divide-Two-Integers/cpp-0029/) | | |
| 030 | [Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words/) | [solution](https://leetcode.com/problems/substring-with-concatenation-of-all-words/solution/) | [C++](0001-0500/0030-Substring-with-Concatenation-of-All-Words/cpp-0030/) | | |
| 031 | [Next Permutation](https://leetcode.com/problems/next-permutation/) | [solution](https://leetcode.com/problems/next-permutation/solution/) | [C++](0001-0500/0031-Next-Permutation/cpp-0031/) | | |
| | | | | | |
| 033 | [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/description/) | [solution](https://leetcode.com/problems/search-in-rotated-sorted-array/solution/) | [C++](0001-0500/0033-Search-in-Rotated-Sorted-Array/cpp-0033/) | | |
| 034 | [Search for a Range](https://leetcode.com/problems/search-for-a-range/description/) | [solution](https://leetcode.com/problems/search-for-a-range/solution/) | [C++](0001-0500/0034-Search-for-a-Range/cpp-0034/) | | |
| 035 | [Search Insert Position](https://leetcode.com/problems/search-insert-position/) | [solution](https://leetcode.com/problems/search-insert-position/solution/) | [C++](0001-0500/0035-Search-Insert-Position/cpp-0035/) | | |
| 036 | [Valid Sudoku](https://leetcode.com/problems/valid-sudoku/description/) | [solution](https://leetcode.com/problems/valid-sudoku/solution/) | [C++](0001-0500/0036-Valid-Sudoku/cpp-0036/) | | |
| 037 | [Sudoku Solver](https://leetcode.com/problems/sudoku-solver/description/) | [solution](https://leetcode.com/problems/sudoku-solver/)
[缺:Dancing Links] | [C++](0001-0500/0037-Sudoku-Solver/cpp-0037/) | [C++](0001-0500/0037-Sudoku-Solver/java-0037/) | |
| 038 | [Count and Say](https://leetcode.com/problems/count-and-say/description/) | [无] | [C++](0001-0500/0038-Count-and-Say/cpp-0038/) | | |
| 039 | [Combination Sum](https://leetcode.com/problems/combination-sum/description/) | [无] | [C++](0001-0500/0039-Combination-Sum/cpp-0039/) | | |
| 040 | [Combination Sum II](https://leetcode.com/problems/combination-sum-ii/description/) | [无] | [C++](0001-0500/0040-Combination-Sum-II/cpp-0040/) | | |
| 041 | [First Missing Positive](https://leetcode.com/problems/first-missing-positive/) | [solution](https://leetcode.com/problems/first-missing-positive/solution/) | [C++](0001-0500/0041-First-Missing-Positive/cpp-0041/) | | |
| 042 | [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/description/) | [solution](https://leetcode.com/problems/trapping-rain-water/solution/) | [C++](0001-0500/0042-Trapping-Rain-Water/cpp-0042/) | | |
| 043 | [Multiply Strings](https://leetcode.com/problems/multiply-strings/) | [solution](https://leetcode.com/problems/multiply-strings/solution/) | [C++](0001-0500/0043-Multiply-Strings/cpp-0043/) | | |
| | | | | | |
| 045 | [Jump Game II](https://leetcode.com/problems/jump-game-ii/) | [solution](https://leetcode.com/problems/jump-game-ii/solution/) | [C++](0001-0500/0045-Jump-Game-II/cpp-0045/) | | |
| 046 | [Permutations](https://leetcode.com/problems/permutations/description/) | [solution](https://leetcode.com/problems/permutations/solution/)
[缺:排列算法整理] | [C++](0001-0500/0046-Permutations/cpp-0046/) | [Java](0001-0500/0046-Permutations/java-0046/src/) | |
| 047 | [Permutations II](https://leetcode.com/problems/permutations-ii/description/) | [无] | [C++](0001-0500/0047-Permutations-II/cpp-0047/) | | |
| 048 | [Rotate Image](https://leetcode.com/problems/rotate-image/description/) | [solution](https://leetcode.com/problems/rotate-image/) | [C++