lc-java
lc-java copied to clipboard
Clean Leetcode solutions in Java
Leetcode in Java
Clean Leetcode solutions in Java
What are included?
| # | Description | Solution | Performance |
|---|---|---|---|
| 1 | Two Sum | TwoSum.java | Beat 98.8% |
| 2 | Add Two Numbers | AddTwoNumbers.java | Beat 100% |
| 3 | Longest Substring Without repeating Characters | LongestSubstrNoRepeatChars.java | Beat 99.86% |
| 4 | Median of Two Sorted Arrays | MedianTwoSortedArrays.java | Beat 100.00% |
| 5 | Longest Palindromic Substring | LongestPalindromicSubstring.java | Beat 86.88% |
| 6 | ZigZag Conversion | ZigZagConversion.java | Beat 95.76% |
| 7 | Reverse Integer | ReverseInteger.java | Beat 100% |
| 8 | String to Integer | StringToInteger.java | Beat 100% |
| 9 | Palindrome Number | PalindromeNumber.java | Beat 100% |
| 10 | Regular Expression Matching | RegularExpressionMatching.java | Beat 93.19% |
| 11 | Container With Most Water | ContainerWithMostWater.java | Beat 95.44% |
| 12 | Integer to Roman | IntegerToRoman.java | Beat 81.64 |
| 13 | Roman to Integer | RomanToInteger.java | Beat 75.68 |
| 14 | Longest Common Prefix | LongestCommonPrefix.java | Beat 100.00% |
| 15 | 3 Sum | ThreeSum.java | Beat 92.57% |
| 16 | 3 Sum Closest | ThreeSumClosest.java | Beat 86.03% |
| 17 | Letter Combinations of a Phone Number | TelephoneKeypad.java | Beat 72.3% |
| 18 | 4 Sum | FourSum.java | Beat 83.12% |
| 19 | Remove Nth Node From End of List | RemoveNodeEndOfList.java | Beat 100.00% |
| 20 | Valid Parentheses | ValidParentheses.java | Beat 98.71% |
| 21 | Merge Two Sorted Lists | MergeTwoSortedLists.java | Beat 100% |
| 22 | Generate Parentheses | GenerateParentheses.java | Beat 87.83% |
| 23 | Merge k Sorted Lists | MergeKSortedLists.java | Beat 81.78% |
| 24 | Swap Nodes in Pairs | SwapNodesInPairs.java | Beat 100% |
| 914 | X of a Kind in a Deck of Cards | GroupsOfCards.java | Beat 74.39% |
FAQs
I saw some of the solutions are not beating 100% of submissions, should I still use them as reference for interview preparation?
Yes. Some of them don't have perfect runtime due to the following reasons:
-
Leetcode online judge test runner is unstable. It sometimes slows down the solutions' runtime by milliseconds, which has big impacts on their performance percentile.
-
Some of the Leetcode submissions are over optimized for online judge system, such as putting all business logic in a giant function, using math tricks, or hardcode all test cases. The giant function approach sacrifices code cleanness, which is one of the important grading metrics for coding interviews. The math tricks cannot assess how good you are at coding, which is another grading metric of coding interview.
License
This project is maintained under MIT license.