Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tech-cow/leetcode

👏🏻 leetcode solutions for Humans™
https://github.com/tech-cow/leetcode

algiorithimcs algorithm algorithm-challenges algorithm-competitions algorithms algorithms-and-data-structures algorithms-datastructures google interview interview-practice interview-preparation interview-questions interview-test leetcode leetcode-python leetcode-solutions python python-leetcode

Last synced: about 2 months ago
JSON representation

👏🏻 leetcode solutions for Humans™

Awesome Lists containing this project

README

        



yuzhoujr



公瑾现在提供以下服务哟!Contact me @ [email protected]

http://yuzhoujr.com/legacy/dummynode.pdf






## Mock Interview 经验 + 反馈

* Google面试官的反馈: [Dropbox链接](https://paper.dropbox.com/doc/GMock-Interview--AIMRqf_e~KjKAe47PIvkVrN6AQ-8teeNVpJ2oq8s6nODLKQd)
* Yahoo电面反馈: [Dropbox链接](https://paper.dropbox.com/doc/95-Yahoo--AMA9j51_WIY9uAzybM9E0QLSAQ-t0hgbpyY11v0NvI3bcEf9)

## Journey

[时间线](https://gist.github.com/yuzhoujr/cf7c0ebdc0b3b471ddac94a862a0ecd9)




## Array Easy
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|624| [Maximum Distance in Arrays](https://leetcode.com/problems/maximum-distance-in-arrays/description/) | [Python](./array/624.py) | _O(n)_| _O(1)_ ||

## Array Medium
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|3| [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/#/solutions) | [Python](./array/3.py) | _O(n)_| _O(n)_ ||
|463| [Island Perimeter](https://leetcode.com/problems/island-perimeter/#/description) | [Python](./array/463.py) | _O(n^2)_| _O(1)_||

## Hash Table Easy
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|1| [Two Sum](https://leetcode.com/problems/two-sum/) | [Python](./array/1.py) | _O(n)_| _O(n)_ |[:tv:](https://www.youtube.com/watch?v=uajne4jeGaA)|
|242| [Valid Anagram](https://leetcode.com/problems/valid-anagram/description/) | [Python](./array/242.py) | _O(n)_| _O(n)_ ||

## Linked List Easy
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|21|[Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists) | [Python](./linkedlist/MergeTwoSortedLists.py) | _O(n)_| _O(n)_ ||
|89|[Partition List](https://leetcode.com/problems/partition-list/) | [Python](./linkedlist/PartitionLinkedList.py) | _O(n)_ | _O(n)_ ||
|141|[Linked List Cycle](https://leetcode.com/problems/linked-list-cycle/#/description) | [Python](./linkedlist/LinkedListCycle.py) | _O(n)_ | _O(1)_ ||
|160|[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists) | [Python](./linkedlist/IntersectionOfTwoLinkedLists.py) | _O(n)_| _O(1)_ ||
|203|[Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements/#/description) | [Python](./linkedlist/RemoveLinkedListElements.py) | _O(n)_| _O(1)_ ||
|206|[Reverse Linked List](https://leetcode.com/problems/reverse-linked-list/#/description) | [Python](./linkedlist/ReverseLinkedList.py) | _O(n)_| _O(1)_ || Tutorial](https://www.youtube.com/watch?v=sYcOK51hl-A&t=681s) |
|234|[Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list/) | [Python](./linkedlist/palindrome.py) | _O(n)_| _O(1)_ ||
|83|[Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list/#/description)| [Python](./linkedlist/deleteDuplicates.py) | _O(n)_| _O(1)_ ||

## LinkedList Medium
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers/#/description) | [Python](./linkedlist/addTwoNumbers.py) | _O(n)_| _O(n)_|
|445| [Add Two Numbers II](https://leetcode.com/problems/add-two-numbers-ii/#/description)| [Python](./linkedlist/addTwoNumbersTwo.py) | _O(n)_| _O(n)_|
|142|[Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii/#/description)| [Python](./linkedlist/detectCycleii.py) | _O(n)_| _O(1)_|[:tv:](https://www.youtube.com/watch?v=iZVBVCpmugI&t=1s)|
|328|[Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list/#/description)| [Python](./linkedlist/oddEvenList.py) | _O(n)_| _O(1)_|
|143|[Reorder List](https://leetcode.com/problems/reorder-list/#/description)| [Python](./linkedlist/reorder.py) | _O(n)_| _O(1)_|
|24|[Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs/#/solutions)| [Python](./linkedlist/swapPairs.py) | _O(n)_| _O(1)_|
|148|[Sort List](https://leetcode.com/problems/sort-list/#/description)| [Python](./linkedlist/sortList.py) | _O(nlogn)_| _O(1)_|
|61|[Rotate List](https://leetcode.com/problems/rotate-list/#/description)| [Python](./linkedlist/rotateRight.py) | _O(n)_| _O(1)_|
|19|[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/#/description)| [Python](./linkedlist/removeNthFromEnd.py) | _O(n)_| _O(1)_|[:tv:](https://youtu.be/8Jq8ikIeF1M)|
|138|[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer/#/description)| [Python](./linkedlist/copyRandomList.py) | _O(n)_| _O(n)_|

## Stacks Easy
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|155|[Min Stack](https://leetcode.com/problems/min-stack/#/description)| [Python](./stack_queue/minStack.py) | _O(1)_| _O(n)_|
|225|[Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues/#/description)| [Python](./stack_queue/queueStack.py) | push/pop: _O(1)_ top:_O(n)_ | _O(n)_|
|20|[Valid Parentheses](https://leetcode.com/problems/valid-parentheses/#/description)| [Python](./stack_queue/isValid.py) | _O(n)_| _O(n)_|
|346|[Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream/#/description)| [Python](./stack_queue/movingAverage.py) | _O(1)_| _O(n)_|

## Tree Easy
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree/#/description)| [Python ](./tree/Yu/110_isBalanced.py) | _O(N)_| _O(h)_ |
|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii/)| [Python ](./tree/Yu/107.py) | _O(N)_| _O(h)_ |
|112|[Path Sum](https://leetcode.com/problems/path-sum/#/description)| [Python ](./tree/Yu/112_hasPathSum.py) | _O(N)_| _O(h)_ |[:tv:](https://www.youtube.com/watch?v=LgtcGjIuE18&feature=youtu.be)|
|100|[Same Tree](https://leetcode.com/problems/same-tree/)| [Python ](./tree/Yu/100_isSameTree.py) | _O(N)_| _O(1)_|
|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree/#/description)| [Python ](./tree/Yu/101_symmetricTree.py)| _O(N)_| _O(1)_|[:tv:](https://youtu.be/3Gl4F29LVpQ)|
|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)| [Python](./tree/Yu/104_maxDepth.py) | _O(N)_| _O(1)_ ||
|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/#/solutions)| [Python ](./tree/Yu/108.py) | _O(N)_| _O(N)_ |[:tv:](https://www.youtube.com/watch?v=lBrb4fXPcMM)|
|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/#/description)| [Python ](https://github.com/yuzhoujr/LeetCode/blob/master/tree/Yu/111_minDepth.py)| _O(N)_| _O(1)_||
|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/#/description)| [Python](./tree/Yu/235_lca_bst.py) | _O(N)_| _O(1)_ ||
|226|[Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree/#/description)| [Python ](./tree/Yu/226.py) | _O(N)_| _O(1)_ |[:tv:](https://youtu.be/oiX3mqcAK0s)|
|543|[Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/#/description)| [Python ](./tree/Yu/543.py) | _O(N)_| _O(h)_ |[:tv:](https://www.youtube.com/watch?v=0VnOfu2pYTo)|
|501|[Find Mode in Binary Search Tree](https://leetcode.com/problems/find-mode-in-binary-search-tree/#/description)| [Python ](./tree/Yu/501.py) | _O(N)_| _O(N)_ |[:tv:](https://youtu.be/v4F4x_uwMb8)|
|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths/#/description)| [Python ](./tree/Yu/257.py) | _O(N)_| _O(N)_ |[:tv:](https://youtu.be/Zr_7qq2f16k)|
|572|[Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree/#/description)| [Python ](./tree/Yu/572.py) | _O(S*T)_| _O(1)_ |[:tv:](https://youtu.be/v4F4x_uwMb8)|
|437|[Path Sum III](https://leetcode.com/problems/path-sum-iii/#/description)| [Python ](./tree/Yu/437.py) | _O(N^2)_| _O(1)_ | |[:tv:](https://www.youtube.com/watch?v=NTyOEYYyv-o)|
|404|[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves/#/description)| [Python ](./tree/Yu/404_sum_of_Left_Leaves.py) | _O(N)_| _O(1)_|[:tv:](https://youtu.be/pH-KxPcBF_4)|
|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value/#/description)| [Python ](./tree/Yu/270.py)| _O(N)_| _O(1)_|[:tv:](https://youtu.be/RwvQyKJxHZk)|
|563|[Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt/#/description)| [Python ](./tree/Yu/563.py) | _O(N)_| _O(1)_ |[:tv:](https://youtu.be/47FQVP4ynk0)|
|538|[Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree/#/description)| [Python ](./tree/Yu/538.py) | _O(N)_| _O(1)_ |[:tv:](https://youtu.be/YoEPWtXmkD4)|
|637|[Average of Levels in Binary Tree](https://leetcode.com/problems/average-of-levels-in-binary-tree/)| [Python ](./tree/Yu/637.py) | _O(N)_| _O(1)_ ||

## Tree Medium
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|144|[Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal/#/description)| [Python ](./tree/Yu/144.py) | _O(N)_| _O(N)_ |[:tv:](https://youtu.be/cHbdPonjYS0)|
|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/#/description)| [Python ](./tree/Yu/102.py) | _O(N)_| _O(N)_ |[:tv:](https://youtu.be/IWiprpdSgzg)|
|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii/#/description)| [Python ](./tree/Yu/107.py) | _O(N)_| _O(N)_ ||
|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row/#/description)| [Python ](./tree/Yu/515.py) | _O(N)_| _O(1)_ ||
|236|[Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/#/description)| [Python ](./tree/Yu/236.py) | _O(N)_| _O(1)_ |[:tv:](https://youtu.be/WqNULaUhPCc)|
|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view/#/description)| [Python ](./tree/Yu/199.py) | _O(N)_| _O(N)_ |[:tv:](https://youtu.be/_iKUgRiUYKA)|
|114|[Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list/#/solutions)| [Python ](./tree/Yu/114.py) | _O(N)_| _O(1)_ |[:tv:](https://youtu.be/LfKRZ_qCmYQ)|
|230|[Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst/#/description)| [Python ](./tree/Yu/230.py) | _O(N)_| _O(1)_ |[:tv:](https://youtu.be/CfNRc82ighw)|
|582|[Kill Process](https://leetcode.com/problems/kill-process/#/description)| [Python ](./tree/Yu/582.py) | _O(N)_| _O(N)_ | [:tv:](https://youtu.be/fKR1n35Sj8s)|

## Backtrack Medium
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|78|[Subsets](https://leetcode.com/problems/subsets/#/description)| [Python ](./backtrack/Yu/78.py) | _O(N*(2^N))_| _O(2^N)_|[:tv:](https://youtu.be/Az3PfUep7gk)|
|90|[Subsets II](https://leetcode.com/problems/subsets-ii/#/description)| [Python ](./backtrack/Yu/90.py) | _O(N*(2^N))_| _O(2^N)_ | [:tv:](https://youtu.be/Az3PfUep7gk)|
|46|[Permutations](https://leetcode.com/problems/permutations/#/description)| [Python ](./backtrack/Yu/46.py) | _O(N*(N!))_| _O(N!)_ | [:tv:](https://www.youtube.com/watch?v=oCGMwvKUQ_I&feature=youtu.be)|
|47|[Permutations II](https://leetcode.com/problems/permutations/#/description)| [Python ](./backtrack/Yu/47.py) | _O(N*(N!))_| _O(N!)_ | [:tv:](https://youtu.be/imLl2s9Ujis)|
|60|[Permutation Sequence](https://leetcode.com/problems/permutation-sequence/#/description)| [Python ](./backtrack/Yu/60.py) | _O(N * (N!)_| _O(N)_ ||
|77|[Combinations](https://leetcode.com/problems/combinations/#/description)| [Python ](./backtrack/Yu/77.py) | _O(N*(N!))_| _O(N!)_ ||
|39|[Combination Sum](https://leetcode.com/problems/combination-sum/#/description)| [Python ](./backtrack/Yu/39.py) | _O(K * (2^N)_| _O(N)_ | [:tv:](https://youtu.be/HdS5dOaz-mk)|
|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii/#/solutions)| [Python ](./backtrack/Yu/39.py) | _O(K * (2^N)_| _O(N)_ | [:tv:](https://youtu.be/HdS5dOaz-mk)|
|216|[Combination Sum III](https://leetcode.com/problems/combination-sum-iii/#/description)| [Python ](./backtrack/Yu/216.py) | _O(K * (2^N)_| _O(N)_ ||
|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/)| [Python ](./backtrack/Yu/17.py) | _O(N*(4^N))_| _O(N)_ | [:tv:](https://www.youtube.com/watch?v=7KZWLM9QtRA)|
|131|[Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning/description/)| [Python ](./backtrack/Yu/131.py) | _O(N*(2^N))_| _O(N)_ | [:tv:](https://youtu.be/UFdSC_ml4TQ)|

## Greedy Medium
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|452|[Minimum Number of Arrows to Burst Balloons](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/#/description)| [Python ](./greedy/452.py) | _O(N)_| _O(1)_ | |

## Dynamic Programming Easy
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|70|[Climbing Stairs](https://leetcode.com/problems/climbing-stairs/#/solutions)| [Python ](./dp/70.py) | _O(N)_| _O(1)_ | Easy| |
|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray/#/description)| [Python ](./dp/53.py) | _O(N)_| _O(N)_ | Easy|[:tv:](https://youtu.be/4tfhDdgu76E) |
|198|[House Robber](https://leetcode.com/problems/house-robber/#/description)| [Python ](./dp/198.py) | _O(N)_| _O(N)_ | Easy|[:tv:](https://youtu.be/QSjPkgyxCaQ) |

## Dynamic Programming Medium
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|64|[Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum/#/submissions/1)| [Python ](./dp/64.py) | _O(N^2)_| _O(M*N)_ | [:tv:](https://youtu.be/bEcW6QqgXvM)|
|62|[Unique Paths](https://leetcode.com/problems/unique-paths/#/description)| [Python ](./dp/62.py) | _O(N^2)_| _O(M*N)_ | Reference #64|
|55|[Jump Game](https://leetcode.com/problems/jump-game/)| [Python ](./dp/55.py) | _O(N^2)_| _O(1)_ | TLE with DP/Use Greedy for O(N) Solution|
|45|[Jump Game II](https://leetcode.com/problems/jump-game-ii/#/description)| [Python ](./dp/55.py) | _O(N^2)_| _O(1)_ | TLE with DP/Use Greedy for O(N) Solution |
|300|[Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/#/description)| [Python ](./dp/300.py) | _O(N^2)_| _O(1)_ | Use Binary-Search for NlogN Solution|

## BitMap Easy
| # | Title | Solution | Time | Space | Video|
| --- | ----- | -------- | ---- | ----- | ---- |
|136|[Single Number](https://leetcode.com/problems/single-number/description/)| [Python ](./bitmap/136.py) | _O(N)_| _O(1)_ | [:tv:](https://www.youtube.com/watch?v=C4GWPpNivfI&list=PLFp7f5kTehDlpCj5puB3WGbH1Qi3eSDat&index=6&t=7s)|

## Contributors

This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].

## Backers

Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/leetcode#backer)]

## Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/leetcode#sponsor)]










## License

🌱 MIT @ Yu Zhou 🌱

---

> ![home](http://yuzhoujr.com/legacy/emoji/home.svg)
[yuzhoujr.com](http://www.yuzhoujr.com)  · 
> ![github](http://yuzhoujr.com/legacy/emoji/github.svg) [@yuzhoujr](https://github.com/yuzhoujr)  · 
> ![linkedin](http://yuzhoujr.com/legacy/emoji/linkedin.svg) [@yuzhoujr](https://linkedin.com/in/yuzhoujr)