X Tutup
# leetcode-python-java > 🚀 **Level Up Your Developer Identity** > > While mastering algorithms is key, showcasing your talent is what gets you hired. > > We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers. > > **The All-In-One Career Powerhouse:** > - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site. > - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever. > - ✨ **Premium Subdomains:** Stand out with elite tech handle like `yourname.leader.me`. > > [**Build Your Programmer Brand at leader.me →**](https://www.leader.me) --- **Not only** Python & Java solutions for LeetCode problems, but also => ## LeetCode Python/Java/JavaScript/C#/Go/Ruby Solutions Dear LeetCoders! For a better LeetCode problem-solving experience, please visit website [LeetCode.blog](https://leetcode.blog): Dare to claim the best practices of LeetCode solutions! Will save you a lot of time! Hi there! I'm Jian. Do you feel that there are too many problems (over 3,450) on the LeetCode and you can't finish them all? Or do you forget how to solve the problems you did last time? If you can master some solution patterns, this will happen less often. Here, I will provide you with **common problem-solving patterns** so that you don't waste time on problems that are not often tested in interviews. **Python, C++, Java, JavaScript, C#, Go, Ruby** languages' solutions are provided for every selected LeetCode problem. Other languages' solutions will be provided in the future. If you have better solutions, welcome to create an issue or PR! # How to Use this "leetcode-python-java" Repository? ## LeetCode Official Study Plan You can do questions according to your own preferences, such as completing all questions of 'LeetCode 75' first. - [LeetCode 75](https://leetcode.blog/en/tags/75) solved in Python, Java, C++, JavaScript, C#, Go and Ruby. - [LeetCode Top 100 Liked](https://leetcode.blog/en/tags/100) solved in Python, Java, C++, JavaScript, C#, Go and Ruby. - [LeetCode Top Interview 150](https://leetcode.blog/en/tags/150) solved in Python, Java, C++, JavaScript, C#, Go and Ruby. # Study Plan by Jian I have planned a learning route for you. You just need to do the problems in the order they are listed. You can skip the more difficult problems and do them later. # Array ## Required problems - [344. Reverse String](en/1-1000/344-reverse-string.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/344-reverse-string.md) - [27. Remove Element](en/1-1000/27-remove-element.md) Python, Java, C++, JavaScript, C#, Go, Ruby, **2** approaches. [中文](zh/1-1000/27-remove-element.md) - [605. Can Place Flowers](en/1-1000/605-can-place-flowers.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/605-can-place-flowers.md) - [238. Product of Array Except Self](en/1-1000/238-product-of-array-except-self.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/238-product-of-array-except-self.md) - [704. Binary Search](en/1-1000/704-binary-search.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/704-binary-search.md) - [977. Squares of a Sorted Array](en/1-1000/977-squares-of-a-sorted-array.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/977-squares-of-a-sorted-array.md) - [209. Minimum Size Subarray Sum](en/1-1000/209-minimum-size-subarray-sum.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/209-minimum-size-subarray-sum.md) - [303. Range Sum Query - Immutable](en/1-1000/303-range-sum-query-immutable.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/303-range-sum-query-immutable.md) - [59. Spiral Matrix II](en/1-1000/59-spiral-matrix-ii.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/59-spiral-matrix-ii.md) - [503. Next Greater Element II](en/1-1000/503-next-greater-element-ii.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/503-next-greater-element-ii.md) - [3478. Choose K Elements With Maximum Sum](https://leetcode.blog/en/leetcode/3478-choose-k-elements-with-maximum-sum) Python. [中文](https://leetcode.blog/zh/leetcode/3478-choose-k-elements-with-maximum-sum) ## Optional problems - [88. Merge Sorted Array](en/1-1000/88-merge-sorted-array.md) Python, Java, Ruby. [中文](zh/1-1000/88-merge-sorted-array.md) - [169. Majority Element](en/1-1000/169-majority-element.md) Python, Java, Ruby. [中文](zh/1-1000/169-majority-element.md) - [26. Remove Duplicates from Sorted Array](en/1-1000/26-remove-duplicates-from-sorted-array.md) Easy. Python, Java, Ruby. [中文](zh/1-1000/26-remove-duplicates-from-sorted-array.md) # Linked List ## Required problems - [203. Remove Linked List Elements](en/1-1000/203-remove-linked-list-elements.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/203-remove-linked-list-elements.md) - [206. Reverse Linked List](en/1-1000/206-reverse-linked-list.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/206-reverse-linked-list.md) - [160. Intersection of Two Linked Lists](en/1-1000/160-intersection-of-two-linked-lists.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/160-intersection-of-two-linked-lists.md) - [19. Remove Nth Node From End of List](en/1-1000/19-remove-nth-node-from-end-of-list.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/19-remove-nth-node-from-end-of-list.md) - [707. Design Linked List](en/1-1000/707-design-linked-list.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/707-design-linked-list.md) - [24. Swap Nodes in Pairs](en/1-1000/24-swap-nodes-in-pairs.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/24-swap-nodes-in-pairs.md) # Hash Table ## Required problems - [349. Intersection of Two Arrays](en/1-1000/349-intersection-of-two-arrays.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/349-intersection-of-two-arrays.md) - [242. Valid Anagram](en/1-1000/242-valid-anagram.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/242-valid-anagram.md) - [1. Two Sum](en/1-1000/1-two-sum.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/1-two-sum.md) - [383. Ransom Note](en/1-1000/383-ransom-note.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/383-ransom-note.md) - [202. Happy Number](en/1-1000/202-happy-number.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/202-happy-number.md) - [454. 4Sum II](en/1-1000/454-4sum-ii.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/454-4sum-ii.md) - [49. Group Anagrams](https://leetcode.blog/en/leetcode/49-group-anagrams) Python, Ruby. [中文](https://leetcode.blog/zh/leetcode/49-group-anagrams) # String ## Required problems - [28. Find the Index of the First Occurrence in a String](en/1-1000/28-find-the-index-of-the-first-occurrence-in-a-string.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/28-find-the-index-of-the-first-occurrence-in-a-string.md) - [541. Reverse String II](en/1-1000/541-reverse-string-ii.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/541-reverse-string-ii.md) - [1768. Merge Strings Alternately](en/1001-2000/1768-merge-strings-alternately.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1001-2000/1768-merge-strings-alternately.md) - [1431. Kids With the Greatest Number of Candies](en/1001-2000/1431-kids-with-the-greatest-number-of-candies.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1001-2000/1431-kids-with-the-greatest-number-of-candies.md) - [151. Reverse Words in a String](en/1-1000/151-reverse-words-in-a-string.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/151-reverse-words-in-a-string.md) - [459. Repeated Substring Pattern](en/1-1000/459-repeated-substring-pattern.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/459-repeated-substring-pattern.md) - [833. Find, Replace in String](https://leetcode.blog/en/leetcode/833-find-and-replace-in-string) Python. [中文](https://leetcode.blog/zh/leetcode/833-find-and-replace-in-string) - [1071. Greatest Common Divisor of Strings](en/1001-2000/1071-greatest-common-divisor-of-strings.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1001-2000/1071-greatest-common-divisor-of-strings.md) ## Optional problems - [13. Roman to Integer](en/1-1000/13-roman-to-integer.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/13-roman-to-integer.md) - [58. Length of Last Word](en/1-1000/58-length-of-last-word.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/58-length-of-last-word.md) - [14. Longest Common Prefix](en/1-1000/14-longest-common-prefix.md) Python, Java, Ruby. [中文](zh/1-1000/14-longest-common-prefix.md) - [125. Valid Palindrome](en/1-1000/125-valid-palindrome.md) Python, Java, Ruby. [中文](zh/1-1000/125-valid-palindrome.md) # Two Pointers ## Required problems - [345. Reverse Vowels of a String](en/1-1000/345-reverse-vowels-of-a-string.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/345-reverse-vowels-of-a-string.md) - [15. 3Sum](en/1-1000/15-3sum.md) Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. [中文](zh/1-1000/15-3sum.md) - [18. 4Sum](en/1-1000/18-4sum.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/18-4sum.md) - [443. String Compression](en/1-1000/443-string-compression.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/443-string-compression.md) # Stack & Queue ## Required problems - [20. Valid Parentheses](en/1-1000/20-valid-parentheses.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/20-valid-parentheses.md) - [232. Implement Queue using Stacks](en/1-1000/232-implement-queue-using-stacks.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/232-implement-queue-using-stacks.md) - [225. Implement Stack using Queues](en/1-1000/225-implement-stack-using-queues.md) Python, Java, C++, JavaScript, C#, Go, Ruby, 3 approaches. [中文](zh/1-1000/225-implement-stack-using-queues.md) # Binary Tree ## Required problems - [144. Binary Tree Preorder Traversal](en/1-1000/144-binary-tree-preorder-traversal.md) Python, 2 approaches. [中文](zh/1-1000/144-binary-tree-preorder-traversal.md) # Greedy Algorithm ## Required problems - [334. Increasing Triplet Subsequence](en/1-1000/334-increasing-triplet-subsequence.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/334-increasing-triplet-subsequence.md) # Dynamic Programming ## Required problems ### Easy Problems - [509. Fibonacci Number](en/1-1000/509-fibonacci-number.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/509-fibonacci-number.md) ### House Robber - [198. House Robber](en/1-1000/198-house-robber.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/198-house-robber.md) - [213. House Robber II](en/1-1000/213-house-robber-ii.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/213-house-robber-ii.md) - [337. House Robber III](en/1-1000/337-house-robber-iii.md) Python, Java, C++, JavaScript, C#, Go, Ruby, **2** approaches. [中文](zh/1-1000/337-house-robber-iii.md) ### Knapsack Problems #### 0/1 Knapsack - [416. Partition Equal Subset Sum](en/1-1000/416-partition-equal-subset-sum.md) Python, Java, C++, JavaScript, C#, Go, Ruby, **2** approaches. [中文](zh/1-1000/416-partition-equal-subset-sum.md) - [1049. Last Stone Weight II](en/1001-2000/1049-last-stone-weight-ii.md) Python, Java, C++, JavaScript, C#, Go, Ruby, **2** approaches. [中文](zh/1001-2000/1049-last-stone-weight-ii.md) - [494. Target Sum](en/1-1000/494-target-sum.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/494-target-sum.md) - [474. Ones and Zeroes](en/1-1000/474-ones-and-zeroes.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/474-ones-and-zeroes.md) #### Unbounded Knapsack - [518. Coin Change II](en/1-1000/518-coin-change-ii.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/518-coin-change-ii.md) - [377. Combination Sum IV](en/1-1000/377-combination-sum-iv.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/377-combination-sum-iv.md) - [322. Coin Change](en/1-1000/322-coin-change.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/322-coin-change.md) - [279. Perfect Squares](en/1-1000/279-perfect-squares.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/279-perfect-squares.md) - [139. Word Break](en/1-1000/139-word-break.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/139-word-break.md) ### Stock Maximum Profit Problems - [121. Best Time to Buy and Sell Stock](en/1-1000/121-best-time-to-buy-and-sell-stock.md) Python, JavaScript, Go. [中文](zh/1-1000/121-best-time-to-buy-and-sell-stock.md) - [122. Best Time to Buy and Sell Stock II](en/1-1000/122-best-time-to-buy-and-sell-stock-ii.md) Python, JavaScript, Go. [中文](zh/1-1000/122-best-time-to-buy-and-sell-stock-ii.md) - [714. Best Time to Buy and Sell Stock with Transaction Fee](en/1-1000/714-best-time-to-buy-and-sell-stock-with-transaction-fee.md) Python, JavaScript, Go. [中文](zh/1-1000/714-best-time-to-buy-and-sell-stock-with-transaction-fee.md) - [123. Best Time to Buy and Sell Stock III](en/1-1000/123-best-time-to-buy-and-sell-stock-iii.md) Python, JavaScript, Go. [中文](zh/1-1000/123-best-time-to-buy-and-sell-stock-iii.md) - [188. Best Time to Buy and Sell Stock IV](en/1-1000/188-best-time-to-buy-and-sell-stock-iv.md) Python, JavaScript, Go. [中文](zh/1-1000/188-best-time-to-buy-and-sell-stock-iv.md) - [309. Best Time to Buy and Sell Stock with Cooldown](en/1-1000/309-best-time-to-buy-and-sell-stock-with-cooldown.md) Python, JavaScript, Go. [中文](zh/1-1000/309-best-time-to-buy-and-sell-stock-with-cooldown.md) ### Subsequence Problems - [674. Longest Continuous Increasing Subsequence](en/1-1000/674-longest-continuous-increasing-subsequence.md) Python, Java, JavaScript, C#. [中文](zh/1-1000/674-longest-continuous-increasing-subsequence.md) - [300. Longest Increasing Subsequence](en/1-1000/300-longest-increasing-subsequence.md) Python, Java, JavaScript, C#. [中文](zh/1-1000/300-longest-increasing-subsequence.md) - [718. Maximum Length of Repeated Subarray](en/1-1000/718-maximum-length-of-repeated-subarray.md) Python, Java, JavaScript, C#. [中文](zh/1-1000/718-maximum-length-of-repeated-subarray.md) - [1143. Longest Common Subsequence](en/1001-2000/1143-longest-common-subsequence.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1001-2000/1143-longest-common-subsequence.md) - [1035. Uncrossed Lines](en/1001-2000/1035-uncrossed-lines.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1001-2000/1035-uncrossed-lines.md) - [53. Maximum Subarray](en/1-1000/53-maximum-subarray.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/53-maximum-subarray.md) - [392. Is Subsequence](en/1-1000/392-is-subsequence.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/392-is-subsequence.md) - [583. Delete Operation for Two Strings](en/1-1000/583-delete-operation-for-two-strings.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/583-delete-operation-for-two-strings.md) - [72. Edit Distance](en/1-1000/72-edit-distance.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/72-edit-distance.md) ### Hard Problems - [3494. Find the Minimum Amount of Time to Brew Potions](https://leetcode.blog/en/leetcode/3494-find-the-minimum-amount-of-time-to-brew-potions) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](https://leetcode.blog/zh/leetcode/3494-find-the-minimum-amount-of-time-to-brew-potions) ## Optional problems - [5. Longest Palindromic Substring](en/1-1000/5-longest-palindromic-substring.md) Ruby. [中文](zh/1-1000/5-longest-palindromic-substring.md) # Monotonic Stack ## Required problems - [739. Daily Temperatures](en/1-1000/739-daily-temperatures.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/739-daily-temperatures.md) - [496. Next Greater Element I](en/1-1000/496-next-greater-element-i.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/496-next-greater-element-i.md) - [42. Trapping Rain Water](en/1-1000/42-trapping-rain-water.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/42-trapping-rain-water.md) - [84. Largest Rectangle in Histogram](en/1-1000/84-largest-rectangle-in-histogram.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/84-largest-rectangle-in-histogram.md) # Graph Theory ## Required problems - [797. All Paths From Source to Target](en/1-1000/797-all-paths-from-source-to-target.md) Python, Java, C++, JavaScript, C#, Go, Ruby, **2** approaches. [中文](zh/1-1000/797-all-paths-from-source-to-target.md) - [200. Number of Islands](en/1-1000/200-number-of-islands.md) Python, Java, C++, JavaScript, C#, Go, Ruby, **3** approaches. [中文](zh/1-1000/200-number-of-islands.md) - [463. Island Perimeter](en/1-1000/463-island-perimeter.md) Python, **2** approaches. [中文](zh/1-1000/463-island-perimeter.md) - [695. Max Area of Island](en/1-1000/695-max-area-of-island.md) Python, Java, C++, JavaScript, C#, Go, Ruby, **3** approaches. [中文](zh/1-1000/695-max-area-of-island.md) - [827. Making A Large Island](en/1-1000/827-making-a-large-island.md) Python, **2** approaches. [中文](zh/1-1000/827-making-a-large-island.md) - [127. Word Ladder](en/1-1000/127-word-ladder.md) Python. [中文](zh/1-1000/127-word-ladder.md) - [1971. Find if Path Exists in Graph](en/1001-2000/1971-find-if-path-exists-in-graph.md) Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. [中文](zh/1001-2000/1971-find-if-path-exists-in-graph.md) - [684. Redundant Connection](en/1-1000/684-redundant-connection.md) Python, Java, C++, JavaScript, C#, Go, Ruby. [中文](zh/1-1000/684-redundant-connection.md) - [685. Redundant Connection II](en/1-1000/685-redundant-connection-ii.md) Python. [中文](zh/1-1000/685-redundant-connection-ii.md) - [1584. Min Cost to Connect All Points](en/1001-2000/1584-min-cost-to-connect-all-points.md) Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. [中文](zh/1001-2000/1584-min-cost-to-connect-all-points.md) - [207. Course Schedule](en/1-1000/207-course-schedule.md) Python, Java, C++, C#, 2 approaches. [中文](zh/1-1000/207-course-schedule.md) - [1514. Path with Maximum Probability](en/1001-2000/1514-path-with-maximum-probability.md) Python, 2 approaches. [中文](zh/1001-2000/1514-path-with-maximum-probability.md) - [752. Open the Lock](en/1-1000/752-open-the-lock.md) Python, 2 approaches. [中文](zh/1-1000/752-open-the-lock.md) - [743. Network Delay Time](en/1-1000/743-network-delay-time.md) Python, 2 approaches. [中文](zh/1-1000/743-network-delay-time.md) - [787. Cheapest Flights Within K Stops](en/1-1000/787-cheapest-flights-within-k-stops.md) Python. [中文](zh/1-1000/787-cheapest-flights-within-k-stops.md) - [1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance](en/1001-2000/1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance.md) Python. [中文](zh/1001-2000/1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance.md) # Other Algorithms - [433. Minimum Genetic Mutation](en/1-1000/433-minimum-genetic-mutation.md) Python, 3 approaches. [中文](zh/1-1000/433-minimum-genetic-mutation.md) # "leetcode-python-java": More Problems More LeetCode problems and solutions will be added soon. Updated every week. --- > 🚀 **Level Up Your Developer Identity** > > While mastering algorithms is key, showcasing your talent is what gets you hired. > > We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers. > > **The All-In-One Career Powerhouse:** > - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site. > - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever. > - ✨ **Premium Subdomains:** Stand out with elite tech handle like `yourname.leader.me`. > > [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
X Tutup