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
#82Medium

Remove Duplicates from Sorted List II

Linked ListTwo Pointers

Acceptance: 52.2%

#86Medium

Partition List

Linked ListTwo Pointers

Acceptance: 62.0%

#89Medium

Gray Code

BacktrackingBit ManipulationMath

Acceptance: 65.6%

#90Medium

Subsets II

ArrayBacktrackingBit Manipulation

Acceptance: 61.7%

#91Medium

Decode Ways

Dynamic ProgrammingString

Acceptance: 38.3%

#92Medium

Reverse Linked List II

Linked List

Acceptance: 52.4%

#93Medium

Restore IP Addresses

BacktrackingString

Acceptance: 56.7%

#95Medium

Unique Binary Search Trees II

BacktrackingBinary Search TreeBinary Tree+2

Acceptance: 63.3%

#96Medium

Unique Binary Search Trees

Binary Search TreeBinary TreeDynamic Programming+2

Acceptance: 64.0%

#97Medium

Interleaving String

Dynamic ProgrammingString

Acceptance: 44.4%

#98Medium

Validate Binary Search Tree

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 36.1%

#99Medium

Recover Binary Search Tree

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 60.9%

#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%

#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%

#109Medium

Convert Sorted List to Binary Search Tree

Binary Search TreeBinary TreeDivide and Conquer+2

Acceptance: 67.4%

#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%

#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%

#120Medium

Triangle

ArrayDynamic Programming

Acceptance: 59.9%

#122Medium

Best Time to Buy and Sell Stock II

ArrayDynamic ProgrammingGreedy

Acceptance: 71.4%

#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%

#133Medium

Clone Graph

Breadth-First SearchDepth-First SearchGraph+1

Acceptance: 66.1%

#134Medium

Gas Station

ArrayGreedy

Acceptance: 48.4%

#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%

#142Medium

Linked List Cycle II

Hash TableLinked ListTwo Pointers

Acceptance: 58.7%

#143Medium

Reorder List

Linked ListRecursionStack+1

Acceptance: 66.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%

#150Medium

Evaluate Reverse Polish Notation

ArrayMathStack

Acceptance: 58.5%

#151Medium

Reverse Words in a String

StringTwo Pointers

Acceptance: 57.8%

#152Medium

Maximum Product Subarray

ArrayDynamic Programming

Acceptance: 36.7%

#153Medium

Find Minimum in Rotated Sorted Array

ArrayBinary Search

Acceptance: 55.3%

#155Medium

Min Stack

DesignStack

Acceptance: 58.5%

#156Medium

Binary Tree Upside Down

Binary TreeDepth-First SearchTree

Acceptance: 65.4%

#159Medium

Longest Substring with At Most Two Distinct Characters

Hash TableSliding WindowString

Acceptance: 57.0%

#161Medium

One Edit Distance

StringTwo Pointers

Acceptance: 34.4%

#162Medium

Find Peak Element

ArrayBinary Search

Acceptance: 46.8%

#164Medium

Maximum Gap

ArrayBucket SortRadix Sort+1

Acceptance: 52.8%

#165Medium

Compare Version Numbers

StringTwo Pointers

Acceptance: 46.8%

#166Medium

Fraction to Recurring Decimal

Hash TableMathString

Acceptance: 31.3%

Page 2 of 43

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