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

Minimum Index Sum of Common Elements

ArrayHash Table

Acceptance: 77.5%

#3733Medium

Minimum Time to Complete All Deliveries

Binary SearchMath

Acceptance: 35.4%

#3719Medium

Longest Balanced Subarray I

ArrayDivide and ConquerHash Table+2

Acceptance: 65.6%

#3849Medium

Maximum Bitwise XOR After Rearrangement

Bit ManipulationGreedyString

Acceptance: 70.4%

#3724Medium

Minimum Operations to Transform Array

ArrayGreedy

Acceptance: 39.5%

#3693Medium

Climbing Stairs II

ArrayDynamic Programming

Acceptance: 63.9%

#3672Medium

Sum of Weighted Modes in Subarrays

ArrayCountingHash Table+2

Acceptance: 53.7%

#3702Medium

Longest Subsequence With Non-Zero Bitwise XOR

ArrayBit Manipulation

Acceptance: 55.1%

#3825Medium

Longest Strictly Increasing Subsequence With Non-Zero Bitwise AND

ArrayBinary SearchBit Manipulation+1

Acceptance: 49.5%

#3857Medium

Minimum Cost to Split into Ones

Dynamic ProgrammingMath

Acceptance: 82.6%

#3694Medium

Distinct Points Reachable After Substring Removal

Hash TablePrefix SumSliding Window+1

Acceptance: 53.9%

#3720Medium

Lexicographically Smallest Permutation Greater Than Target

CountingEnumerationGreedy+2

Acceptance: 48.2%

#3703Medium

Remove K-Balanced Substrings

SimulationStackString

Acceptance: 33.1%

#3776Medium

Minimum Moves to Balance Circular Array

ArrayGreedySorting

Acceptance: 40.2%

#3698Medium

Split Array With Minimum Difference

ArrayPrefix Sum

Acceptance: 33.6%

#3853Medium

Merge Close Characters

Hash TableString

Acceptance: 54.8%

#3656Medium

Determine if a Simple Graph Exists

ArrayBinary SearchGraph+2

Acceptance: 47.5%

#3689Medium

Maximum Total Subarray Value I

ArrayGreedy

Acceptance: 71.9%

#3708Medium

Longest Fibonacci Subarray

Array

Acceptance: 68.5%

#3676Medium

Count Bowl Subarrays

ArrayMonotonic StackStack

Acceptance: 48.7%

#3675Medium

Minimum Operations to Transform String

GreedyString

Acceptance: 61.9%

#3641Medium

Longest Semi-Repeating Subarray

ArrayHash TableSliding Window

Acceptance: 63.9%

#3680Medium

Generate Schedule

ArrayGreedyMath

Acceptance: 25.3%

#3647Medium

Maximum Weight in Two Bags

ArrayDynamic Programming

Acceptance: 58.3%

#3742Medium

Maximum Path Score in a Grid

ArrayDynamic ProgrammingMatrix

Acceptance: 53.7%

#3660Medium

Jump Game IX

ArrayDynamic Programming

Acceptance: 46.1%

#3652Medium

Best Time to Buy and Sell Stock using Strategy

ArrayPrefix SumSliding Window

Acceptance: 59.8%

#3659Medium

Partition Array Into K-Distinct Groups

ArrayCountingHash Table

Acceptance: 47.1%

#3653Medium

XOR After Range Multiplication Queries I

ArrayDivide and ConquerSimulation

Acceptance: 73.3%

#3631Medium

Sort Threats by Severity and Exploitability

ArraySorting

Acceptance: 63.3%

#3635Medium

Earliest Finish Time for Land and Water Rides II

ArrayBinary SearchGreedy+2

Acceptance: 64.2%

#3654Medium

Minimum Sum After Divisible Sum Deletions

ArrayDynamic ProgrammingHash Table+1

Acceptance: 45.9%

#3649Medium

Number of Perfect Pairs

ArrayMathSorting+1

Acceptance: 34.2%

#3616Medium

Number of Student Replacements

ArraySimulation

Acceptance: 86.0%

#3645Medium

Maximum Total from Optimal Activation Order

ArrayGreedyHeap (Priority Queue)+2

Acceptance: 33.1%

#3634Medium

Minimum Removals to Balance Array

ArrayBinary SearchSliding Window+1

Acceptance: 47.9%

#3638Medium

Maximum Balanced Shipments

ArrayDynamic ProgrammingGreedy+2

Acceptance: 61.4%

#3679Medium

Minimum Discards to Balance Inventory

ArrayCountingHash Table+2

Acceptance: 34.9%

#3644Medium

Maximum K to Sort a Permutation

ArrayBit Manipulation

Acceptance: 37.3%

#3610Medium

Minimum Number of Primes to Sum to Target

ArrayDynamic ProgrammingMath+1

Acceptance: 59.8%

#3628Medium

Maximum Number of Subsequences After One Inserting

Dynamic ProgrammingGreedyPrefix Sum+1

Acceptance: 32.4%

#3669Medium

Balanced K-Factor Decomposition

BacktrackingMathNumber Theory

Acceptance: 40.2%

#3755Medium

Find Maximum Balanced XOR Subarray Length

ArrayBit ManipulationHash Table+1

Acceptance: 50.8%

#3648Medium

Minimum Sensors to Cover Grid

Math

Acceptance: 67.6%

#3639Medium

Minimum Time to Activate String

ArrayBinary Search

Acceptance: 48.6%

#3665Medium

Twisted Mirror Path Count

ArrayDynamic ProgrammingMatrix

Acceptance: 47.5%

#3618Medium

Split Array by Prime Indices

ArrayMathNumber Theory

Acceptance: 49.3%

#3595Medium

Once Twice

ArrayBit Manipulation

Acceptance: 76.1%

#3629Medium

Minimum Jumps to Reach End via Prime Teleportation

ArrayBreadth-First SearchHash Table+2

Acceptance: 44.6%

#3612Medium

Process String with Special Operations I

SimulationString

Acceptance: 71.4%

Page 38 of 43

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