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
#51Hard

N-Queens

ArrayBacktracking

Acceptance: 76.3%

#52Hard

N-Queens II

Backtracking

Acceptance: 78.9%

#53Medium

Maximum Subarray

ArrayDivide and ConquerDynamic Programming

Acceptance: 53.7%

#54Medium

Spiral Matrix

ArrayMatrixSimulation

Acceptance: 57.6%

#55Medium

Jump Game

ArrayDynamic ProgrammingGreedy

Acceptance: 41.2%

#56Medium

Merge Intervals

ArraySorting

Acceptance: 52.6%

#57Medium

Insert Interval

Array

Acceptance: 45.5%

#58Easy

Length of Last Word

String

Acceptance: 59.7%

#59Medium

Spiral Matrix II

ArrayMatrixSimulation

Acceptance: 75.4%

#60Hard

Permutation Sequence

MathRecursion

Acceptance: 54.3%

#61Medium

Rotate List

Linked ListTwo Pointers

Acceptance: 43.1%

#62Medium

Unique Paths

CombinatoricsDynamic ProgrammingMath

Acceptance: 67.3%

#63Medium

Unique Paths II

ArrayDynamic ProgrammingMatrix

Acceptance: 44.9%

#64Medium

Minimum Path Sum

ArrayDynamic ProgrammingMatrix

Acceptance: 68.6%

#65Hard

Valid Number

String

Acceptance: 23.3%

#66Easy

Plus One

ArrayMath

Acceptance: 50.3%

#67Easy

Add Binary

Bit ManipulationMathSimulation+1

Acceptance: 58.4%

#68Hard

Text Justification

ArraySimulationString

Acceptance: 51.8%

#69Easy

Sqrt(x)

Binary SearchMath

Acceptance: 42.2%

#70Easy

Climbing Stairs

Dynamic ProgrammingMathMemoization

Acceptance: 54.0%

#71Medium

Simplify Path

StackString

Acceptance: 51.4%

#72Medium

Edit Distance

Dynamic ProgrammingString

Acceptance: 60.9%

#73Medium

Set Matrix Zeroes

ArrayHash TableMatrix

Acceptance: 63.2%

#74Medium

Search a 2D Matrix

ArrayBinary SearchMatrix

Acceptance: 54.4%

#75Medium

Sort Colors

ArraySortingTwo Pointers

Acceptance: 69.9%

#76Hard

Minimum Window Substring

Hash TableSliding WindowString

Acceptance: 48.3%

#77Medium

Combinations

Backtracking

Acceptance: 74.9%

#78Medium

Subsets

ArrayBacktrackingBit Manipulation

Acceptance: 82.7%

#79Medium

Word Search

ArrayBacktrackingMatrix+1

Acceptance: 48.2%

#80Medium

Remove Duplicates from Sorted Array II

ArrayTwo Pointers

Acceptance: 65.0%

#81Medium

Search in Rotated Sorted Array II

ArrayBinary Search

Acceptance: 40.4%

#82Medium

Remove Duplicates from Sorted List II

Linked ListTwo Pointers

Acceptance: 52.2%

#83Easy

Remove Duplicates from Sorted List

Linked List

Acceptance: 57.0%

#84Hard

Largest Rectangle in Histogram

ArrayMonotonic StackStack

Acceptance: 50.7%

#85Hard

Maximal Rectangle

ArrayDynamic ProgrammingMatrix+2

Acceptance: 59.5%

#86Medium

Partition List

Linked ListTwo Pointers

Acceptance: 62.0%

#87Hard

Scramble String

Dynamic ProgrammingString

Acceptance: 45.3%

#88Easy

Merge Sorted Array

ArraySortingTwo Pointers

Acceptance: 55.7%

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

#94Easy

Binary Tree Inorder Traversal

Binary TreeDepth-First SearchStack+1

Acceptance: 80.4%

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

#100Easy

Same Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 68.0%

Page 2 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