Easy LeetCode Problems: All 760, With Python Solutions

Easy problems test whether you can turn a stated requirement into working code without fumbling the mechanics. The technique is usually named in the problem; the work is the edge cases.

The rating is LeetCode's own, carried through unchanged — we do not re-score anything. This library holds 760 Easy-rated problems, 588 of them with a complete Python solution, a worked example and complexity analysis.

The patterns behind easy problems

The six patterns with the most Easy-rated problems in this library. Working through a pattern beats working down a difficulty list, because the technique transfers and a difficulty band does not.

  • Hash Map · 227 Easy problems — Trade memory for time: remember what you have seen so the second pass never happens.
  • Math and Number Theory · 121 Easy problems — Find the closed form, the invariant, or the modular identity — and skip the loop entirely.
  • Sorting · 80 Easy problems — Spend O(n log n) once to buy an ordering that makes the rest of the problem trivial.
  • Two Pointers · 58 Easy problems — Use the order already in the input to discard half the search space at every step.
  • Depth-First Search · 41 Easy problems — Follow one path to its end before trying the next — the default way to explore a graph.
  • Greedy · 41 Easy problems — Take the locally best option every time — when you can prove that never costs you later.

Easy problems

Showing the first 200 of 760 problems. Problems with a complete Python solution are listed first, then by ascending problem number.

#ProblemDifficultyTopics
1Two SumEasyArray, Hash Table
9Palindrome NumberEasyMath
13Roman to IntegerEasyHash Table, Math, String
14Longest Common PrefixEasyTrie, Array, String
20Valid ParenthesesEasyStack, String
21Merge Two Sorted ListsEasyRecursion, Linked List
26Remove Duplicates from Sorted ArrayEasyArray, Two Pointers
27Remove ElementEasyArray, Two Pointers
28Find the Index of the First Occurrence in a StringEasyTwo Pointers, String, String Matching
35Search Insert PositionEasyArray, Binary Search
58Length of Last WordEasyString
66Plus OneEasyArray, Math
67Add BinaryEasyBit Manipulation, Math, String +1
69Sqrt(x)EasyMath, Binary Search
70Climbing StairsEasyMemoization, Math, Dynamic Programming
83Remove Duplicates from Sorted ListEasyLinked List
88Merge Sorted ArrayEasyArray, Two Pointers, Sorting
94Binary Tree Inorder TraversalEasyStack, Tree, Depth-First Search +1
100Same TreeEasyTree, Depth-First Search, Breadth-First Search +1
101Symmetric TreeEasyTree, Depth-First Search, Breadth-First Search +1
104Maximum Depth of Binary TreeEasyTree, Depth-First Search, Breadth-First Search +1
108Convert Sorted Array to Binary Search TreeEasyTree, Binary Search Tree, Array +2
110Balanced Binary TreeEasyTree, Depth-First Search, Binary Tree
111Minimum Depth of Binary TreeEasyTree, Depth-First Search, Breadth-First Search +1
112Path SumEasyTree, Depth-First Search, Breadth-First Search +1
118Pascal's TriangleEasyArray, Dynamic Programming
119Pascal's Triangle IIEasyArray, Dynamic Programming
121Best Time to Buy and Sell StockEasyArray, Dynamic Programming
125Valid PalindromeEasyTwo Pointers, String
136Single NumberEasyBit Manipulation, Array
141Linked List CycleEasyHash Table, Linked List, Two Pointers
144Binary Tree Preorder TraversalEasyStack, Tree, Depth-First Search +1
145Binary Tree Postorder TraversalEasyStack, Tree, Depth-First Search +1
160Intersection of Two Linked ListsEasyHash Table, Linked List, Two Pointers
168Excel Sheet Column TitleEasyMath, String
169Majority ElementEasyArray, Hash Table, Divide and Conquer +2
171Excel Sheet Column NumberEasyMath, String
175Combine Two TablesEasyDatabase
181Employees Earning More Than Their ManagersEasyDatabase
182Duplicate EmailsEasyDatabase
183Customers Who Never OrderEasyDatabase
190Reverse BitsEasyBit Manipulation, Divide and Conquer
191Number of 1 BitsEasyBit Manipulation, Divide and Conquer
193Valid Phone NumbersEasyShell
195Tenth LineEasyShell
196Delete Duplicate EmailsEasyDatabase
197Rising TemperatureEasyDatabase
202Happy NumberEasyHash Table, Math, Two Pointers
203Remove Linked List ElementsEasyRecursion, Linked List
205Isomorphic StringsEasyHash Table, String
206Reverse Linked ListEasyRecursion, Linked List
217Contains DuplicateEasyArray, Hash Table, Sorting
219Contains Duplicate IIEasyArray, Hash Table, Sliding Window
222Count Complete Tree NodesEasyBit Manipulation, Tree, Binary Search +1
225Implement Stack using QueuesEasyStack, Design, Queue
226Invert Binary TreeEasyTree, Depth-First Search, Breadth-First Search +1
228Summary RangesEasyArray
231Power of TwoEasyBit Manipulation, Recursion, Math
232Implement Queue using StacksEasyStack, Design, Queue
234Palindrome Linked ListEasyStack, Recursion, Linked List +1
242Valid AnagramEasyHash Table, String, Sorting
257Binary Tree PathsEasyTree, Depth-First Search, String +2
258Add DigitsEasyMath, Number Theory, Simulation
263Ugly NumberEasyMath
268Missing NumberEasyBit Manipulation, Array, Hash Table +3
278First Bad VersionEasyBinary Search, Interactive
283Move ZeroesEasyArray, Two Pointers
290Word PatternEasyHash Table, String
292Nim GameEasyBrainteaser, Math, Game Theory
303Range Sum Query - ImmutableEasyDesign, Array, Prefix Sum
326Power of ThreeEasyRecursion, Math
338Counting BitsEasyBit Manipulation, Dynamic Programming
342Power of FourEasyBit Manipulation, Recursion, Math
344Reverse StringEasyTwo Pointers, String
345Reverse Vowels of a StringEasyTwo Pointers, String
349Intersection of Two ArraysEasyArray, Hash Table, Two Pointers +2
350Intersection of Two Arrays IIEasyArray, Hash Table, Two Pointers +2
367Valid Perfect SquareEasyMath, Binary Search
374Guess Number Higher or LowerEasyBinary Search, Interactive
383Ransom NoteEasyHash Table, String, Counting
387First Unique Character in a StringEasyQueue, Hash Table, String +1
389Find the DifferenceEasyBit Manipulation, Hash Table, String +1
392Is SubsequenceEasyTwo Pointers, String, Dynamic Programming
401Binary WatchEasyBit Manipulation, Backtracking
404Sum of Left LeavesEasyTree, Depth-First Search, Breadth-First Search +1
405Convert a Number to HexadecimalEasyBit Manipulation, Math, String
409Longest PalindromeEasyGreedy, Hash Table, String
412Fizz BuzzEasyMath, String, Simulation
414Third Maximum NumberEasyArray, Sorting
415Add StringsEasyMath, String, Simulation
434Number of Segments in a StringEasyString
441Arranging CoinsEasyMath, Binary Search
448Find All Numbers Disappeared in an ArrayEasyArray, Hash Table
455Assign CookiesEasyGreedy, Array, Two Pointers +1
459Repeated Substring PatternEasyString, String Matching
461Hamming DistanceEasyBit Manipulation
463Island PerimeterEasyDepth-First Search, Breadth-First Search, Array +1
476Number ComplementEasyBit Manipulation
482License Key FormattingEasyString
485Max Consecutive OnesEasyArray
492Construct the RectangleEasyMath
495Teemo AttackingEasyArray, Simulation
496Next Greater Element IEasyStack, Array, Hash Table +1
500Keyboard RowEasyArray, Hash Table, String
501Find Mode in Binary Search TreeEasyTree, Depth-First Search, Binary Search Tree +1
504Base 7EasyMath, String
506Relative RanksEasyArray, Sorting, Heap (Priority Queue)
507Perfect NumberEasyMath
509Fibonacci NumberEasyRecursion, Memoization, Math +1
511Game Play Analysis IEasyDatabase
520Detect CapitalEasyString
521Longest Uncommon Subsequence IEasyString
530Minimum Absolute Difference in BSTEasyTree, Depth-First Search, Breadth-First Search +2
541Reverse String IIEasyTwo Pointers, String
543Diameter of Binary TreeEasyTree, Depth-First Search, Binary Tree
551Student Attendance Record IEasyString
557Reverse Words in a String IIIEasyTwo Pointers, String
559Maximum Depth of N-ary TreeEasyTree, Depth-First Search, Breadth-First Search
561Array PartitionEasyGreedy, Array, Counting Sort +1
563Binary Tree TiltEasyTree, Depth-First Search, Binary Tree
566Reshape the MatrixEasyArray, Matrix, Simulation
572Subtree of Another TreeEasyTree, Depth-First Search, Binary Tree +2
575Distribute CandiesEasyArray, Hash Table
577Employee BonusEasyDatabase
584Find Customer RefereeEasyDatabase
586Customer Placing the Largest Number of OrdersEasyDatabase
589N-ary Tree Preorder TraversalEasyStack, Tree, Depth-First Search
590N-ary Tree Postorder TraversalEasyStack, Tree, Depth-First Search
594Longest Harmonious SubsequenceEasyArray, Hash Table, Counting +2
595Big CountriesEasyDatabase
596Classes With at Least 5 StudentsEasyDatabase
598Range Addition IIEasyArray, Math
599Minimum Index Sum of Two ListsEasyArray, Hash Table, String
605Can Place FlowersEasyGreedy, Array
607Sales PersonEasyDatabase
610Triangle JudgementEasyDatabase
617Merge Two Binary TreesEasyTree, Depth-First Search, Breadth-First Search +1
619Biggest Single NumberEasyDatabase
620Not Boring MoviesEasyDatabase
627Swap Sex of EmployeesEasyDatabase
628Maximum Product of Three NumbersEasyArray, Math, Sorting
637Average of Levels in Binary TreeEasyTree, Depth-First Search, Breadth-First Search +1
643Maximum Average Subarray IEasyArray, Sliding Window
645Set MismatchEasyBit Manipulation, Array, Hash Table +1
653Two Sum IV - Input is a BSTEasyTree, Depth-First Search, Breadth-First Search +4
657Robot Return to OriginEasyString, Simulation
661Image SmootherEasyArray, Matrix
671Second Minimum Node In a Binary TreeEasyTree, Depth-First Search, Binary Tree
674Longest Continuous Increasing SubsequenceEasyArray
680Valid Palindrome IIEasyGreedy, Two Pointers, String
682Baseball GameEasyStack, Array, Simulation
693Binary Number with Alternating BitsEasyBit Manipulation
696Count Binary SubstringsEasyTwo Pointers, String
697Degree of an ArrayEasyArray, Hash Table
700Search in a Binary Search TreeEasyTree, Binary Search Tree, Binary Tree
703Kth Largest Element in a StreamEasyTree, Design, Binary Search Tree +3
704Binary SearchEasyArray, Binary Search
705Design HashSetEasyDesign, Array, Hash Table +2
706Design HashMapEasyDesign, Array, Hash Table +2
709To Lower CaseEasyString
7171-bit and 2-bit CharactersEasyArray
724Find Pivot IndexEasyArray, Prefix Sum
728Self Dividing NumbersEasyMath
733Flood FillEasyDepth-First Search, Breadth-First Search, Array +1
744Find Smallest Letter Greater Than TargetEasyArray, Binary Search
746Min Cost Climbing StairsEasyArray, Dynamic Programming
747Largest Number At Least Twice of OthersEasyArray, Sorting
748Shortest Completing WordEasyArray, Hash Table, String
762Prime Number of Set Bits in Binary RepresentationEasyBit Manipulation, Math
766Toeplitz MatrixEasyArray, Matrix
771Jewels and StonesEasyHash Table, String
783Minimum Distance Between BST NodesEasyTree, Depth-First Search, Breadth-First Search +2
796Rotate StringEasyString, String Matching
804Unique Morse Code WordsEasyArray, Hash Table, String
806Number of Lines To Write StringEasyArray, String
812Largest Triangle AreaEasyGeometry, Array, Math
819Most Common WordEasyArray, Hash Table, String +1
821Shortest Distance to a CharacterEasyArray, Two Pointers, String
824Goat LatinEasyString
830Positions of Large GroupsEasyString
832Flipping an ImageEasyBit Manipulation, Array, Two Pointers +2
836Rectangle OverlapEasyGeometry, Math
844Backspace String CompareEasyStack, Two Pointers, String +1
859Buddy StringsEasyHash Table, String
860Lemonade ChangeEasyGreedy, Array
867Transpose MatrixEasyArray, Matrix, Simulation
868Binary GapEasyBit Manipulation
872Leaf-Similar TreesEasyTree, Depth-First Search, Binary Tree
876Middle of the Linked ListEasyLinked List, Two Pointers
883Projection Area of 3D ShapesEasyGeometry, Array, Math +1
884Uncommon Words from Two SentencesEasyHash Table, String, Counting
888Fair Candy SwapEasyArray, Hash Table, Binary Search +1
892Surface Area of 3D ShapesEasyGeometry, Array, Math +1
896Monotonic ArrayEasyArray
897Increasing Order Search TreeEasyStack, Tree, Depth-First Search +2
905Sort Array By ParityEasyArray, Two Pointers, Sorting
908Smallest Range IEasyArray, Math
914X of a Kind in a Deck of CardsEasyArray, Hash Table, Math +2
917Reverse Only LettersEasyTwo Pointers, String
922Sort Array By Parity IIEasyArray, Two Pointers, Sorting

Everything at once: the full LeetCode problem list.

A easy problem, live, with someone watching

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.