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

Remove Invalid Parentheses

BacktrackingBreadth-First SearchString

Acceptance: 49.8%

#302Hard

Smallest Rectangle Enclosing Black Pixels

ArrayBinary SearchBreadth-First Search+2

Acceptance: 60.9%

#305Hard

Number of Islands II

ArrayHash TableUnion Find

Acceptance: 40.5%

#312Hard

Burst Balloons

ArrayDynamic Programming

Acceptance: 64.3%

#315Hard

Count of Smaller Numbers After Self

ArrayBinary Indexed TreeBinary Search+4

Acceptance: 44.0%

#317Hard

Shortest Distance from All Buildings

ArrayBreadth-First SearchMatrix

Acceptance: 44.9%

#321Hard

Create Maximum Number

ArrayGreedyMonotonic Stack+2

Acceptance: 36.7%

#327Hard

Count of Range Sum

ArrayBinary Indexed TreeBinary Search+4

Acceptance: 39.7%

#329Hard

Longest Increasing Path in a Matrix

ArrayBreadth-First SearchDepth-First Search+5

Acceptance: 57.0%

#330Hard

Patching Array

ArrayGreedy

Acceptance: 54.7%

#332Hard

Reconstruct Itinerary

Depth-First SearchEulerian CircuitGraph

Acceptance: 45.0%

#335Hard

Self Crossing

ArrayGeometryMath

Acceptance: 36.3%

#336Hard

Palindrome Pairs

ArrayHash TableString+1

Acceptance: 37.1%

#352Hard

Data Stream as Disjoint Intervals

Binary SearchDesignOrdered Set

Acceptance: 60.2%

#354Hard

Russian Doll Envelopes

ArrayBinary SearchDynamic Programming+1

Acceptance: 37.8%

#358Hard

Rearrange String k Distance Apart

CountingGreedyHash Table+3

Acceptance: 39.9%

#363Hard

Max Sum of Rectangle No Larger Than K

ArrayBinary SearchMatrix+2

Acceptance: 46.0%

#381Hard

Insert Delete GetRandom O(1) - Duplicates allowed

ArrayDesignHash Table+2

Acceptance: 36.5%

#391Hard

Perfect Rectangle

ArrayLine Sweep

Acceptance: 38.8%

#403Hard

Frog Jump

ArrayDynamic Programming

Acceptance: 47.2%

#407Hard

Trapping Rain Water II

ArrayBreadth-First SearchHeap (Priority Queue)+1

Acceptance: 64.0%

#410Hard

Split Array Largest Sum

ArrayBinary SearchDynamic Programming+2

Acceptance: 61.2%

#411Hard

Minimum Unique Word Abbreviation

ArrayBacktrackingBit Manipulation+1

Acceptance: 40.5%

#420Hard

Strong Password Checker

GreedyHeap (Priority Queue)String

Acceptance: 16.1%

#425Hard

Word Squares

ArrayBacktrackingString+1

Acceptance: 54.7%

#428Hard

Serialize and Deserialize N-ary Tree

Breadth-First SearchDepth-First SearchString+1

Acceptance: 68.7%

#431Hard

Encode N-ary Tree to Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+2

Acceptance: 80.6%

#432Hard

All O`one Data Structure

DesignDoubly-Linked ListHash Table+1

Acceptance: 44.2%

#440Hard

K-th Smallest in Lexicographical Order

Trie

Acceptance: 46.2%

#446Hard

Arithmetic Slices II - Subsequence

ArrayDynamic Programming

Acceptance: 55.1%

#458Hard

Poor Pigs

CombinatoricsDynamic ProgrammingMath

Acceptance: 59.4%

#460Hard

LFU Cache

DesignDoubly-Linked ListHash Table+1

Acceptance: 50.0%

#465Hard

Optimal Account Balancing

ArrayBacktrackingBit Manipulation+2

Acceptance: 50.3%

#466Hard

Count The Repetitions

Dynamic ProgrammingString

Acceptance: 36.0%

#471Hard

Encode String with Shortest Length

Dynamic ProgrammingString

Acceptance: 50.5%

#472Hard

Concatenated Words

ArrayDepth-First SearchDynamic Programming+2

Acceptance: 49.9%

#479Hard

Largest Palindrome Product

EnumerationMath

Acceptance: 39.6%

#480Hard

Sliding Window Median

ArrayHash TableHeap (Priority Queue)+1

Acceptance: 38.7%

#483Hard

Smallest Good Base

Binary SearchMath

Acceptance: 47.0%

#488Hard

Zuma Game

Breadth-First SearchDynamic ProgrammingMemoization+2

Acceptance: 29.4%

#489Hard

Robot Room Cleaner

BacktrackingInteractive

Acceptance: 77.9%

#493Hard

Reverse Pairs

ArrayBinary Indexed TreeBinary Search+4

Acceptance: 35.1%

#499Hard

The Maze III

ArrayBreadth-First SearchDepth-First Search+5

Acceptance: 52.3%

#502Hard

IPO

ArrayGreedyHeap (Priority Queue)+1

Acceptance: 53.6%

#514Hard

Freedom Trail

Breadth-First SearchDepth-First SearchDynamic Programming+1

Acceptance: 59.4%

#517Hard

Super Washing Machines

ArrayGreedy

Acceptance: 45.3%

#527Hard

Word Abbreviation

ArrayGreedySorting+2

Acceptance: 62.7%

#546Hard

Remove Boxes

ArrayDynamic ProgrammingMemoization

Acceptance: 49.4%

#548Hard

Split Array with Equal Sum

ArrayHash TablePrefix Sum

Acceptance: 50.1%

#552Hard

Student Attendance Record II

Dynamic Programming

Acceptance: 56.5%

Page 2 of 20

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