LeetCode
LeetCode Question Answers
How to solve LeetCode problems in a coding interview: the idea behind each solution and a working answer in Python, Java, C++ and TypeScript. Open the original problem on LeetCode, try it yourself, then compare with our answer. New answers are added every day.
752 answers
- 1.Two SumEasy
- 2.Add Two NumbersMedium
- 3.Longest Substring Without Repeating CharactersMedium
- 4.Median of Two Sorted ArraysHard
- 5.Longest Palindromic SubstringMedium
- 7.Reverse IntegerMedium
- 8.String to Integer (atoi)Medium
- 9.Palindrome NumberEasy
- 11.Container With Most WaterMedium
- 12.Integer to RomanMedium
- 13.Roman to IntegerEasy
- 14.Longest Common PrefixEasy
- 15.3SumMedium
- 16.3Sum ClosestMedium
- 17.Letter Combinations of a Phone NumberMedium
- 18.4SumMedium
- 19.Remove Nth Node From End of ListMedium
- 20.Valid ParenthesesEasy
- 21.Merge Two Sorted ListsEasy
- 22.Generate ParenthesesMedium
- 23.Merge k Sorted ListsHard
- 24.Swap Nodes in PairsMedium
- 25.Reverse Nodes in k-GroupHard
- 27.Remove ElementEasy
- 28.Find the Index of the First Occurrence in a StringEasy
- 29.Divide Two IntegersMedium
- 30.Substring with Concatenation of All WordsHard
- 31.Next PermutationMedium
- 32.Longest Valid ParenthesesHard
- 33.Search in Rotated Sorted ArrayMedium
- 34.Find First and Last Position of Element in Sorted ArrayMedium
- 35.Search Insert PositionEasy
- 36.Valid SudokuMedium
- 37.Sudoku SolverHard
- 38.Count and SayMedium
- 40.Combination Sum IIMedium
- 41.First Missing PositiveHard
- 42.Trapping Rain WaterHard
- 43.Multiply StringsMedium
- 44.Wildcard MatchingHard
- 45.Jump Game IIMedium
- 46.PermutationsMedium
- 47.Permutations IIMedium
- 48.Rotate ImageMedium
- 49.Group AnagramsMedium
- 50.Pow(x, n)Medium
- 51.N-QueensHard
- 52.N-Queens IIHard
- 53.Maximum SubarrayMedium
- 54.Spiral MatrixMedium
Beyond LeetCode
Real interviews also test system design, SQL, machine learning and behavioral answers. Practise those with KatInterview problems, browse by topic, or read our company interview guides.
LeetCode is a trademark of LeetCode LLC. KatInterview is not affiliated with LeetCode.