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

Online Stock Span

Data StreamDesignMonotonic Stack+1

Acceptance: 69.5%

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

#904Medium

Fruit Into Baskets

ArrayHash TableSliding Window

Acceptance: 52.5%

#905Easy

Sort Array By Parity

ArraySortingTwo Pointers

Acceptance: 76.2%

#906Hard

Super Palindromes

EnumerationMath

Acceptance: 39.9%

#907Medium

Sum of Subarray Minimums

ArrayDynamic ProgrammingMonotonic Stack+1

Acceptance: 39.0%

#908Easy

Smallest Range I

ArrayMath

Acceptance: 74.0%

#909Medium

Snakes and Ladders

ArrayBreadth-First SearchMatrix

Acceptance: 48.0%

#910Medium

Smallest Range II

ArrayGreedyMath+1

Acceptance: 37.8%

#911Medium

Online Election

ArrayBinary SearchDesign+1

Acceptance: 52.8%

#912Medium

Sort an Array

ArrayBucket SortCounting Sort+5

Acceptance: 55.9%

#913Hard

Cat and Mouse

Dynamic ProgrammingGame TheoryGraph+3

Acceptance: 36.2%

#914Easy

X of a Kind in a Deck of Cards

ArrayCountingHash Table+2

Acceptance: 30.4%

#915Medium

Partition Array into Disjoint Intervals

Array

Acceptance: 49.4%

#916Medium

Word Subsets

ArrayHash TableString

Acceptance: 55.9%

#917Easy

Reverse Only Letters

StringTwo Pointers

Acceptance: 68.9%

#918Medium

Maximum Sum Circular Subarray

ArrayDivide and ConquerDynamic Programming+2

Acceptance: 51.5%

#919Medium

Complete Binary Tree Inserter

Binary TreeBreadth-First SearchDesign+1

Acceptance: 65.0%

#920Hard

Number of Music Playlists

CombinatoricsDynamic ProgrammingMath

Acceptance: 60.3%

#921Medium

Minimum Add to Make Parentheses Valid

GreedyStackString

Acceptance: 74.7%

#922Easy

Sort Array By Parity II

ArraySortingTwo Pointers

Acceptance: 71.4%

#923Medium

3Sum With Multiplicity

ArrayCountingHash Table+2

Acceptance: 46.2%

#924Hard

Minimize Malware Spread

ArrayBreadth-First SearchDepth-First Search+3

Acceptance: 43.0%

#925Easy

Long Pressed Name

StringTwo Pointers

Acceptance: 32.8%

#926Medium

Flip String to Monotone Increasing

Dynamic ProgrammingString

Acceptance: 61.5%

#927Hard

Three Equal Parts

ArrayMath

Acceptance: 41.3%

#928Hard

Minimize Malware Spread II

ArrayBreadth-First SearchDepth-First Search+3

Acceptance: 46.2%

#929Easy

Unique Email Addresses

ArrayHash TableString

Acceptance: 67.9%

#930Medium

Binary Subarrays With Sum

ArrayHash TablePrefix Sum+1

Acceptance: 69.7%

#931Medium

Minimum Falling Path Sum

ArrayDynamic ProgrammingMatrix

Acceptance: 60.8%

#932Medium

Beautiful Array

ArrayDivide and ConquerMath

Acceptance: 70.1%

#933Easy

Number of Recent Calls

Data StreamDesignQueue

Acceptance: 78.9%

#934Medium

Shortest Bridge

ArrayBreadth-First SearchDepth-First Search+1

Acceptance: 59.3%

#935Medium

Knight Dialer

Dynamic Programming

Acceptance: 61.8%

#936Hard

Stamping The Sequence

GreedyQueueStack+1

Acceptance: 62.2%

#937Medium

Reorder Data in Log Files

ArraySortingString

Acceptance: 56.6%

#938Easy

Range Sum of BST

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 87.2%

#939Medium

Minimum Area Rectangle

ArrayGeometryHash Table+2

Acceptance: 55.4%

#940Hard

Distinct Subsequences II

Dynamic ProgrammingString

Acceptance: 56.7%

#941Easy

Valid Mountain Array

Array

Acceptance: 35.7%

#942Easy

DI String Match

ArrayGreedyString+1

Acceptance: 81.0%

#943Hard

Find the Shortest Superstring

ArrayBit ManipulationBitmask+2

Acceptance: 45.8%

#944Easy

Delete Columns to Make Sorted

ArrayString

Acceptance: 78.1%

#945Medium

Minimum Increment to Make Array Unique

ArrayCountingGreedy+1

Acceptance: 60.7%

#946Medium

Validate Stack Sequences

ArraySimulationStack

Acceptance: 70.8%

#947Medium

Most Stones Removed with Same Row or Column

Depth-First SearchGraphHash Table+1

Acceptance: 63.4%

#948Medium

Bag of Tokens

ArrayGreedySorting+1

Acceptance: 59.5%

#949Medium

Largest Time for Given Digits

ArrayEnumerationString

Acceptance: 36.0%

#950Medium

Reveal Cards In Increasing Order

ArrayQueueSimulation+1

Acceptance: 83.6%

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