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

Minimum Swaps To Make Sequences Increasing

ArrayDynamic Programming

Acceptance: 42.0%

#802Medium

Find Eventual Safe States

Breadth-First SearchDepth-First SearchGraph+1

Acceptance: 71.6%

#803Hard

Bricks Falling When Hit

ArrayMatrixUnion Find

Acceptance: 37.7%

#804Easy

Unique Morse Code Words

ArrayHash TableString

Acceptance: 83.6%

#805Hard

Split Array With Same Average

ArrayBit ManipulationBitmask+2

Acceptance: 27.5%

#806Easy

Number of Lines To Write String

ArrayString

Acceptance: 72.9%

#807Medium

Max Increase to Keep City Skyline

ArrayGreedyMatrix

Acceptance: 86.2%

#808Medium

Soup Servings

Dynamic ProgrammingMathProbability and Statistics

Acceptance: 59.7%

#809Medium

Expressive Words

ArrayStringTwo Pointers

Acceptance: 46.8%

#810Hard

Chalkboard XOR Game

ArrayBit ManipulationBrainteaser+2

Acceptance: 66.7%

#811Medium

Subdomain Visit Count

ArrayCountingHash Table+1

Acceptance: 77.2%

#812Easy

Largest Triangle Area

ArrayGeometryMath

Acceptance: 72.1%

#813Medium

Largest Sum of Averages

ArrayDynamic ProgrammingPrefix Sum

Acceptance: 55.5%

#814Medium

Binary Tree Pruning

Binary TreeDepth-First SearchTree

Acceptance: 72.3%

#815Hard

Bus Routes

ArrayBreadth-First SearchHash Table

Acceptance: 47.3%

#816Medium

Ambiguous Coordinates

BacktrackingEnumerationString

Acceptance: 56.4%

#817Medium

Linked List Components

ArrayHash TableLinked List

Acceptance: 57.8%

#818Hard

Race Car

Dynamic Programming

Acceptance: 44.7%

#819Easy

Most Common Word

ArrayCountingHash Table+1

Acceptance: 45.0%

#820Medium

Short Encoding of Words

ArrayHash TableString+1

Acceptance: 61.0%

#821Easy

Shortest Distance to a Character

ArrayStringTwo Pointers

Acceptance: 72.7%

#822Medium

Card Flipping Game

ArrayHash Table

Acceptance: 50.7%

#823Medium

Binary Trees With Factors

ArrayDynamic ProgrammingHash Table+1

Acceptance: 52.9%

#824Easy

Goat Latin

String

Acceptance: 69.9%

#825Medium

Friends Of Appropriate Ages

ArrayBinary SearchSorting+1

Acceptance: 49.9%

#826Medium

Most Profit Assigning Work

ArrayBinary SearchGreedy+2

Acceptance: 56.4%

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

#830Easy

Positions of Large Groups

String

Acceptance: 54.4%

#831Medium

Masking Personal Information

String

Acceptance: 56.2%

#832Easy

Flipping an Image

ArrayBit ManipulationMatrix+2

Acceptance: 83.6%

#833Medium

Find And Replace in String

ArrayHash TableSorting+1

Acceptance: 50.9%

#834Hard

Sum of Distances in Tree

Depth-First SearchDynamic ProgrammingGraph+1

Acceptance: 65.8%

#835Medium

Image Overlap

ArrayMatrix

Acceptance: 70.6%

#836Easy

Rectangle Overlap

GeometryMath

Acceptance: 53.0%

#837Medium

New 21 Game

Dynamic ProgrammingMathProbability and Statistics+1

Acceptance: 52.0%

#838Medium

Push Dominoes

Dynamic ProgrammingStringTwo Pointers

Acceptance: 63.0%

#839Hard

Similar String Groups

ArrayBreadth-First SearchDepth-First Search+3

Acceptance: 56.1%

#840Medium

Magic Squares In Grid

ArrayHash TableMath+1

Acceptance: 55.1%

#841Medium

Keys and Rooms

Breadth-First SearchDepth-First SearchGraph

Acceptance: 76.2%

#842Medium

Split Array into Fibonacci Sequence

BacktrackingString

Acceptance: 40.3%

#843Hard

Guess the Word

ArrayGame TheoryInteractive+2

Acceptance: 36.9%

#844Easy

Backspace String Compare

SimulationStackString+1

Acceptance: 49.9%

#845Medium

Longest Mountain in Array

ArrayDynamic ProgrammingEnumeration+1

Acceptance: 42.0%

#846Medium

Hand of Straights

ArrayGreedyHash Table+1

Acceptance: 57.9%

#847Hard

Shortest Path Visiting All Nodes

Bit ManipulationBitmaskBreadth-First Search+2

Acceptance: 65.9%

#848Medium

Shifting Letters

ArrayPrefix SumString

Acceptance: 46.1%

#849Medium

Maximize Distance to Closest Person

Array

Acceptance: 49.7%

#850Hard

Rectangle Area II

ArrayLine SweepOrdered Set+1

Acceptance: 56.7%

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