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.
432 answers
- 89.Gray CodeMedium
- 90.Subsets IIMedium
- 91.Decode WaysMedium
- 92.Reverse Linked List IIMedium
- 93.Restore IP AddressesMedium
- 95.Unique Binary Search Trees IIMedium
- 96.Unique Binary Search TreesMedium
- 97.Interleaving StringMedium
- 99.Recover Binary Search TreeMedium
- 102.Binary Tree Level Order TraversalMedium
- 103.Binary Tree Zigzag Level Order TraversalMedium
- 105.Construct Binary Tree from Preorder and Inorder TraversalMedium
- 107.Binary Tree Level Order Traversal IIMedium
- 113.Path Sum IIMedium
- 114.Flatten Binary Tree to Linked ListMedium
- 116.Populating Next Right Pointers in Each NodeMedium
- 117.Populating Next Right Pointers in Each Node IIMedium
- 122.Best Time to Buy and Sell Stock IIMedium
- 129.Sum Root to Leaf NumbersMedium
- 130.Surrounded RegionsMedium
- 131.Palindrome PartitioningMedium
- 133.Clone GraphMedium
- 137.Single Number IIMedium
- 138.Copy List with Random PointerMedium
- 139.Word BreakMedium
- 142.Linked List Cycle IIMedium
- 143.Reorder ListMedium
- 146.LRU CacheMedium
- 148.Sort ListMedium
- 150.Evaluate Reverse Polish NotationMedium
- 151.Reverse Words in a StringMedium
- 152.Maximum Product SubarrayMedium
- 153.Find Minimum in Rotated Sorted ArrayMedium
- 156.Binary Tree Upside DownMedium
- 159.Longest Substring with At Most Two Distinct CharactersMedium
- 161.One Edit DistanceMedium
- 162.Find Peak ElementMedium
- 164.Maximum GapMedium
- 165.Compare Version NumbersMedium
- 166.Fraction to Recurring DecimalMedium
- 167.Two Sum II - Input Array Is SortedMedium
- 172.Factorial Trailing ZeroesMedium
- 173.Binary Search Tree IteratorMedium
- 179.Largest NumberMedium
- 186.Reverse Words in a String IIMedium
- 189.Rotate ArrayMedium
- 200.Number of IslandsMedium
- 201.Bitwise AND of Numbers RangeMedium
- 204.Count PrimesMedium
- 208.Implement Trie (Prefix Tree)Medium
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.