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.
166 answers
- 543.Diameter of Binary TreeEasy
- 551.Student Attendance Record IEasy
- 557.Reverse Words in a String IIIEasy
- 563.Binary Tree TiltEasy
- 566.Reshape the MatrixEasy
- 575.Distribute CandiesEasy
- 594.Longest Harmonious SubsequenceEasy
- 598.Range Addition IIEasy
- 617.Merge Two Binary TreesEasy
- 628.Maximum Product of Three NumbersEasy
- 637.Average of Levels in Binary TreeEasy
- 645.Set MismatchEasy
- 653.Two Sum IV - Input is a BSTEasy
- 661.Image SmootherEasy
- 671.Second Minimum Node In a Binary TreeEasy
- 680.Valid Palindrome IIEasy
- 682.Baseball GameEasy
- 693.Binary Number with Alternating BitsEasy
- 696.Count Binary SubstringsEasy
- 697.Degree of an ArrayEasy
- 717.1-bit and 2-bit CharactersEasy
- 724.Find Pivot IndexEasy
- 728.Self Dividing NumbersEasy
- 733.Flood FillEasy
- 734.Sentence SimilarityEasy
- 742.To Lower CaseEasy
- 745.Find Smallest Letter Greater Than TargetEasy
- 747.Min Cost Climbing StairsEasy
- 748.Largest Number At Least Twice of OthersEasy
- 749.Shortest Completing WordEasy
- 762.Find Anagram MappingsEasy
- 767.Prime Number of Set Bits in Binary RepresentationEasy
- 775.N-ary Tree Preorder TraversalEasy
- 776.N-ary Tree Postorder TraversalEasy
- 777.Toeplitz MatrixEasy
- 783.Search in a Binary Search TreeEasy
- 789.Kth Largest Element in a StreamEasy
- 792.Binary SearchEasy
- 816.Design HashSetEasy
- 817.Design HashMapEasy
- 818.Similar RGB ColorEasy
- 822.Unique Morse Code WordsEasy
- 824.Number of Lines To Write StringEasy
- 830.Largest Triangle AreaEasy
- 837.Most Common WordEasy
- 851.Goat LatinEasy
- 857.Positions of Large GroupsEasy
- 861.Flipping an ImageEasy
- 889.Buddy StringsEasy
- 890.Lemonade ChangeEasy
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.