Skip to main content

Solutions & Explanations

Browse 4,029+ detailed solutions with multiple approaches, code in Python, Java, C++ and more.

4,029 Solutions961 Easy2102 Medium966 Hard
#101Easy

Symmetric Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 61.5%

#102Medium

Binary Tree Level Order Traversal

Binary TreeBreadth-First SearchTree

Acceptance: 73.5%

#103Medium

Binary Tree Zigzag Level Order Traversal

Binary TreeBreadth-First SearchTree

Acceptance: 64.4%

#104Easy

Maximum Depth of Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 78.6%

#105Medium

Construct Binary Tree from Preorder and Inorder Traversal

ArrayBinary TreeDivide and Conquer+2

Acceptance: 69.1%

#106Medium

Construct Binary Tree from Inorder and Postorder Traversal

ArrayBinary TreeDivide and Conquer+2

Acceptance: 69.4%

#107Medium

Binary Tree Level Order Traversal II

Binary TreeBreadth-First SearchTree

Acceptance: 69.0%

#108Easy

Convert Sorted Array to Binary Search Tree

ArrayBinary Search TreeBinary Tree+2

Acceptance: 75.9%

#109Medium

Convert Sorted List to Binary Search Tree

Binary Search TreeBinary TreeDivide and Conquer+2

Acceptance: 67.4%

#110Easy

Balanced Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 59.2%

#111Easy

Minimum Depth of Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 53.7%

#112Easy

Path Sum

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 55.2%

#113Medium

Path Sum II

BacktrackingBinary TreeDepth-First Search+1

Acceptance: 62.6%

#114Medium

Flatten Binary Tree to Linked List

Binary TreeDepth-First SearchLinked List+2

Acceptance: 71.0%

#115Hard

Distinct Subsequences

Dynamic ProgrammingString

Acceptance: 54.1%

#116Medium

Populating Next Right Pointers in Each Node

Binary TreeBreadth-First SearchDepth-First Search+2

Acceptance: 67.6%

#117Medium

Populating Next Right Pointers in Each Node II

Binary TreeBreadth-First SearchDepth-First Search+2

Acceptance: 57.9%

#118Easy

Pascal's Triangle

ArrayDynamic Programming

Acceptance: 79.4%

#119Easy

Pascal's Triangle II

ArrayDynamic Programming

Acceptance: 67.8%

#120Medium

Triangle

ArrayDynamic Programming

Acceptance: 59.9%

#121Easy

Best Time to Buy and Sell Stock

ArrayDynamic Programming

Acceptance: 57.1%

#122Medium

Best Time to Buy and Sell Stock II

ArrayDynamic ProgrammingGreedy

Acceptance: 71.4%

#123Hard

Best Time to Buy and Sell Stock III

ArrayDynamic Programming

Acceptance: 54.5%

#124Hard

Binary Tree Maximum Path Sum

Binary TreeDepth-First SearchDynamic Programming+1

Acceptance: 42.7%

#125Easy

Valid Palindrome

StringTwo Pointers

Acceptance: 54.2%

#126Hard

Word Ladder II

BacktrackingBreadth-First SearchHash Table+1

Acceptance: 27.7%

#127Hard

Word Ladder

Breadth-First SearchHash TableString

Acceptance: 46.3%

#128Medium

Longest Consecutive Sequence

ArrayHash TableUnion Find

Acceptance: 47.0%

#129Medium

Sum Root to Leaf Numbers

Binary TreeDepth-First SearchTree

Acceptance: 70.3%

#130Medium

Surrounded Regions

ArrayBreadth-First SearchDepth-First Search+2

Acceptance: 46.1%

#131Medium

Palindrome Partitioning

BacktrackingDynamic ProgrammingString

Acceptance: 74.4%

#132Hard

Palindrome Partitioning II

Dynamic ProgrammingString

Acceptance: 37.9%

#133Medium

Clone Graph

Breadth-First SearchDepth-First SearchGraph+1

Acceptance: 66.1%

#134Medium

Gas Station

ArrayGreedy

Acceptance: 48.4%

#135Hard

Candy

ArrayGreedy

Acceptance: 49.3%

#136Easy

Single Number

ArrayBit Manipulation

Acceptance: 78.1%

#137Medium

Single Number II

ArrayBit Manipulation

Acceptance: 67.4%

#138Medium

Copy List with Random Pointer

Hash TableLinked List

Acceptance: 63.2%

#139Medium

Word Break

ArrayDynamic ProgrammingHash Table+3

Acceptance: 49.8%

#140Hard

Word Break II

ArrayBacktrackingDynamic Programming+4

Acceptance: 55.8%

#141Easy

Linked List Cycle

Hash TableLinked ListTwo Pointers

Acceptance: 54.6%

#142Medium

Linked List Cycle II

Hash TableLinked ListTwo Pointers

Acceptance: 58.7%

#143Medium

Reorder List

Linked ListRecursionStack+1

Acceptance: 66.0%

#144Easy

Binary Tree Preorder Traversal

Binary TreeDepth-First SearchStack+1

Acceptance: 76.6%

#145Easy

Binary Tree Postorder Traversal

Binary TreeDepth-First SearchStack+1

Acceptance: 79.0%

#146Medium

LRU Cache

DesignDoubly-Linked ListHash Table+1

Acceptance: 47.6%

#147Medium

Insertion Sort List

Linked ListSorting

Acceptance: 59.9%

#148Medium

Sort List

Divide and ConquerLinked ListMerge Sort+2

Acceptance: 65.2%

#149Hard

Max Points on a Line

ArrayGeometryHash Table+1

Acceptance: 31.0%

#150Medium

Evaluate Reverse Polish Notation

ArrayMathStack

Acceptance: 58.5%

Page 3 of 81

Master DSA with Step-by-Step Solutions

Each solution article on FleetCode breaks down the problem into multiple approaches, from brute force to optimal, with detailed explanations and code in Python, Java, C++ and more. Understanding why an approach works - not just copying code - is what separates candidates who clear interviews from those who don't.

How to Use These Solutions

  • Try the problem first: Spend at least 20 minutes before reading the solution
  • Read all approaches: Start from brute force to understand the problem fully, then study the optimized solution
  • Understand the complexity: Pay attention to time and space analysis for each approach
  • Code it yourself: After understanding the approach, close the solution and implement from memory
  • Revisit after a week: Spaced repetition helps retain problem-solving patterns