GitHub - leetcode-python-java/leetcode-python-java: Solving LeetCode problems in the best way. Python, Java, C++, JavaScript, Go, C# and Ruby are supported! Official website👇🏻:
🚀 Level Up Your Developer Identity
While mastering algorithms is key, showcasing your talent is what gets you hired.
We recommend 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.
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: 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 solved in Python, Java, C++, JavaScript, C#, Go and Ruby.
- LeetCode Top 100 Liked solved in Python, Java, C++, JavaScript, C#, Go and Ruby.
- LeetCode Top Interview 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 Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 27. Remove Element Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. 中文
- 605. Can Place Flowers Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 238. Product of Array Except Self Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 704. Binary Search Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 977. Squares of a Sorted Array Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 209. Minimum Size Subarray Sum Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 303. Range Sum Query - Immutable Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 59. Spiral Matrix II Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 503. Next Greater Element II Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 3478. Choose K Elements With Maximum Sum Python. 中文
Optional problems
- 88. Merge Sorted Array Python, Java, Ruby. 中文
- 169. Majority Element Python, Java, Ruby. 中文
- 26. Remove Duplicates from Sorted Array Easy. Python, Java, Ruby. 中文
Linked List
Required problems
- 203. Remove Linked List Elements Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 206. Reverse Linked List Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 160. Intersection of Two Linked Lists Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 19. Remove Nth Node From End of List Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 707. Design Linked List Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 24. Swap Nodes in Pairs Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Hash Table
Required problems
- 349. Intersection of Two Arrays Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 242. Valid Anagram Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 1. Two Sum Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 383. Ransom Note Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 202. Happy Number Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 454. 4Sum II Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 49. Group Anagrams Python, Ruby. 中文
String
Required problems
- 28. Find the Index of the First Occurrence in a String Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 541. Reverse String II Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 1768. Merge Strings Alternately Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 1431. Kids With the Greatest Number of Candies Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 151. Reverse Words in a String Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 459. Repeated Substring Pattern Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 833. Find, Replace in String Python. 中文
- 1071. Greatest Common Divisor of Strings Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Optional problems
- 13. Roman to Integer Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 58. Length of Last Word Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 14. Longest Common Prefix Python, Java, Ruby. 中文
- 125. Valid Palindrome Python, Java, Ruby. 中文
Two Pointers
Required problems
- 345. Reverse Vowels of a String Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 15. 3Sum Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. 中文
- 18. 4Sum Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 443. String Compression Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Stack & Queue
Required problems
- 20. Valid Parentheses Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 232. Implement Queue using Stacks Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 225. Implement Stack using Queues Python, Java, C++, JavaScript, C#, Go, Ruby, 3 approaches. 中文
Binary Tree
Required problems
- 144. Binary Tree Preorder Traversal Python, 2 approaches. 中文
Greedy Algorithm
Required problems
- 334. Increasing Triplet Subsequence Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Dynamic Programming
Required problems
Easy Problems
- 509. Fibonacci Number Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
House Robber
- 198. House Robber Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 213. House Robber II Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 337. House Robber III Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. 中文
Knapsack Problems
0/1 Knapsack
- 416. Partition Equal Subset Sum Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. 中文
- 1049. Last Stone Weight II Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. 中文
- 494. Target Sum Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 474. Ones and Zeroes Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Unbounded Knapsack
- 518. Coin Change II Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 377. Combination Sum IV Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 322. Coin Change Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 279. Perfect Squares Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 139. Word Break Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Stock Maximum Profit Problems
- 121. Best Time to Buy and Sell Stock Python, JavaScript, Go. 中文
- 122. Best Time to Buy and Sell Stock II Python, JavaScript, Go. 中文
- 714. Best Time to Buy and Sell Stock with Transaction Fee Python, JavaScript, Go. 中文
- 123. Best Time to Buy and Sell Stock III Python, JavaScript, Go. 中文
- 188. Best Time to Buy and Sell Stock IV Python, JavaScript, Go. 中文
- 309. Best Time to Buy and Sell Stock with Cooldown Python, JavaScript, Go. 中文
Subsequence Problems
- 674. Longest Continuous Increasing Subsequence Python, Java, JavaScript, C#. 中文
- 300. Longest Increasing Subsequence Python, Java, JavaScript, C#. 中文
- 718. Maximum Length of Repeated Subarray Python, Java, JavaScript, C#. 中文
- 1143. Longest Common Subsequence Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 1035. Uncrossed Lines Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 53. Maximum Subarray Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 392. Is Subsequence Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 583. Delete Operation for Two Strings Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 72. Edit Distance Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Hard Problems
- 3494. Find the Minimum Amount of Time to Brew Potions Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Optional problems
Monotonic Stack
Required problems
- 739. Daily Temperatures Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 496. Next Greater Element I Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 42. Trapping Rain Water Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 84. Largest Rectangle in Histogram Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
Graph Theory
Required problems
- 797. All Paths From Source to Target Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. 中文
- 200. Number of Islands Python, Java, C++, JavaScript, C#, Go, Ruby, 3 approaches. 中文
- 463. Island Perimeter Python, 2 approaches. 中文
- 695. Max Area of Island Python, Java, C++, JavaScript, C#, Go, Ruby, 3 approaches. 中文
- 827. Making A Large Island Python, 2 approaches. 中文
- 127. Word Ladder Python. 中文
- 1971. Find if Path Exists in Graph Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. 中文
- 684. Redundant Connection Python, Java, C++, JavaScript, C#, Go, Ruby. 中文
- 685. Redundant Connection II Python. 中文
- 1584. Min Cost to Connect All Points Python, Java, C++, JavaScript, C#, Go, Ruby, 2 approaches. 中文
- 207. Course Schedule Python, Java, C++, C#, 2 approaches. 中文
- 1514. Path with Maximum Probability Python, 2 approaches. 中文
- 752. Open the Lock Python, 2 approaches. 中文
- 743. Network Delay Time Python, 2 approaches. 中文
- 787. Cheapest Flights Within K Stops Python. 中文
- 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance Python. 中文
Other Algorithms
- 433. Minimum Genetic Mutation Python, 3 approaches. 中文
"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 — 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.