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

Basic Calculator III

MathRecursionStack+1

Acceptance: 53.2%

#773Hard

Sliding Puzzle

ArrayBacktrackingBreadth-First Search+3

Acceptance: 74.3%

#774Hard

Minimize Max Distance to Gas Station

ArrayBinary Search

Acceptance: 53.9%

#778Hard

Swim in Rising Water

ArrayBinary SearchBreadth-First Search+4

Acceptance: 68.3%

#780Hard

Reaching Points

Math

Acceptance: 34.3%

#782Hard

Transform to Chessboard

ArrayBit ManipulationMath+1

Acceptance: 51.3%

#793Hard

Preimage Size of Factorial Zeroes Function

Binary SearchMath

Acceptance: 47.4%

#798Hard

Smallest Rotation with Highest Score

ArrayPrefix Sum

Acceptance: 54.2%

#801Hard

Minimum Swaps To Make Sequences Increasing

ArrayDynamic Programming

Acceptance: 42.0%

#803Hard

Bricks Falling When Hit

ArrayMatrixUnion Find

Acceptance: 37.7%

#805Hard

Split Array With Same Average

ArrayBit ManipulationBitmask+2

Acceptance: 27.5%

#810Hard

Chalkboard XOR Game

ArrayBit ManipulationBrainteaser+2

Acceptance: 66.7%

#815Hard

Bus Routes

ArrayBreadth-First SearchHash Table

Acceptance: 47.3%

#818Hard

Race Car

Dynamic Programming

Acceptance: 44.7%

#827Hard

Making A Large Island

ArrayBreadth-First SearchDepth-First Search+2

Acceptance: 57.0%

#828Hard

Count Unique Characters of All Substrings of a Given String

Dynamic ProgrammingHash TableString

Acceptance: 53.5%

#829Hard

Consecutive Numbers Sum

EnumerationMath

Acceptance: 42.6%

#834Hard

Sum of Distances in Tree

Depth-First SearchDynamic ProgrammingGraph+1

Acceptance: 65.8%

#839Hard

Similar String Groups

ArrayBreadth-First SearchDepth-First Search+3

Acceptance: 56.1%

#843Hard

Guess the Word

ArrayGame TheoryInteractive+2

Acceptance: 36.9%

#847Hard

Shortest Path Visiting All Nodes

Bit ManipulationBitmaskBreadth-First Search+2

Acceptance: 65.9%

#850Hard

Rectangle Area II

ArrayLine SweepOrdered Set+1

Acceptance: 56.7%

#854Hard

K-Similar Strings

Breadth-First SearchString

Acceptance: 41.3%

#857Hard

Minimum Cost to Hire K Workers

ArrayGreedyHeap (Priority Queue)+1

Acceptance: 63.5%

#862Hard

Shortest Subarray with Sum at Least K

ArrayBinary SearchHeap (Priority Queue)+4

Acceptance: 32.7%

#864Hard

Shortest Path to Get All Keys

ArrayBit ManipulationBreadth-First Search+1

Acceptance: 55.0%

#871Hard

Minimum Number of Refueling Stops

ArrayDynamic ProgrammingGreedy+1

Acceptance: 41.8%

#878Hard

Nth Magical Number

Binary SearchMath

Acceptance: 37.1%

#879Hard

Profitable Schemes

ArrayDynamic Programming

Acceptance: 48.1%

#882Hard

Reachable Nodes In Subdivided Graph

GraphHeap (Priority Queue)Shortest Path

Acceptance: 52.5%

#887Hard

Super Egg Drop

Binary SearchDynamic ProgrammingMath

Acceptance: 30.6%

#891Hard

Sum of Subsequence Widths

ArrayMathSorting

Acceptance: 41.1%

#895Hard

Maximum Frequency Stack

DesignHash TableOrdered Set+1

Acceptance: 67.1%

#899Hard

Orderly Queue

MathSortingString

Acceptance: 66.8%

#902Hard

Numbers At Most N Given Digit Set

ArrayBinary SearchDynamic Programming+2

Acceptance: 45.9%

#903Hard

Valid Permutations for DI Sequence

Dynamic ProgrammingPrefix SumString

Acceptance: 56.3%

#906Hard

Super Palindromes

EnumerationMath

Acceptance: 39.9%

#913Hard

Cat and Mouse

Dynamic ProgrammingGame TheoryGraph+3

Acceptance: 36.2%

#920Hard

Number of Music Playlists

CombinatoricsDynamic ProgrammingMath

Acceptance: 60.3%

#924Hard

Minimize Malware Spread

ArrayBreadth-First SearchDepth-First Search+3

Acceptance: 43.0%

#927Hard

Three Equal Parts

ArrayMath

Acceptance: 41.3%

#928Hard

Minimize Malware Spread II

ArrayBreadth-First SearchDepth-First Search+3

Acceptance: 46.2%

#936Hard

Stamping The Sequence

GreedyQueueStack+1

Acceptance: 62.2%

#940Hard

Distinct Subsequences II

Dynamic ProgrammingString

Acceptance: 56.7%

#943Hard

Find the Shortest Superstring

ArrayBit ManipulationBitmask+2

Acceptance: 45.8%

#952Hard

Largest Component Size by Common Factor

ArrayHash TableMath+2

Acceptance: 43.8%

#956Hard

Tallest Billboard

ArrayDynamic Programming

Acceptance: 52.0%

#960Hard

Delete Columns to Make Sorted III

ArrayDynamic ProgrammingString

Acceptance: 72.7%

#964Hard

Least Operators to Express Number

Dynamic ProgrammingMathMemoization

Acceptance: 48.3%

#968Hard

Binary Tree Cameras

Binary TreeDepth-First SearchDynamic Programming+1

Acceptance: 47.7%

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