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
#3662Easy

Filter Characters by Frequency

CountingHash TableString

Acceptance: 86.2%

#3698Medium

Split Array With Minimum Difference

ArrayPrefix Sum

Acceptance: 33.6%

#3853Medium

Merge Close Characters

Hash TableString

Acceptance: 54.8%

#3683Easy

Earliest Time to Finish One Task

Array

Acceptance: 84.5%

#3678Easy

Smallest Absent Positive Greater Than Average

ArrayHash Table

Acceptance: 34.2%

#3695Hard

Maximize Alternating Sum Using Swaps

ArrayGreedySorting+1

Acceptance: 62.5%

#3688Easy

Bitwise OR of Even Numbers in an Array

ArrayBit ManipulationSimulation

Acceptance: 84.9%

#3668Easy

Restore Finishing Order

ArrayHash Table

Acceptance: 91.1%

#3691Hard

Maximum Total Subarray Value II

ArrayGreedyHeap (Priority Queue)+1

Acceptance: 41.6%

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

#3859Hard

Count Subarrays With K Distinct Integers

ArrayCountingHash Table+1

Acceptance: 21.0%

#3676Medium

Count Bowl Subarrays

ArrayMonotonic StackStack

Acceptance: 48.7%

#3675Medium

Minimum Operations to Transform String

GreedyString

Acceptance: 61.9%

#3674Easy

Minimum Operations to Equalize Array

ArrayBit ManipulationBrainteaser

Acceptance: 60.8%

#3684Easy

Maximize Sum of At Most K Distinct Elements

ArrayGreedyHash Table+1

Acceptance: 76.8%

#3658Easy

GCD of Odd and Even Sums

MathNumber Theory

Acceptance: 89.8%

#3663Easy

Find The Least Frequent Digit

ArrayCountingHash Table+1

Acceptance: 68.8%

#3641Medium

Longest Semi-Repeating Subarray

ArrayHash TableSliding Window

Acceptance: 63.9%

#3680Medium

Generate Schedule

ArrayGreedyMath

Acceptance: 25.3%

#3681Hard

Maximum XOR of Subsequences

ArrayBit ManipulationGreedy+1

Acceptance: 49.5%

#3671Hard

Sum of Beautiful Subsequences

ArrayBinary Indexed TreeMath+1

Acceptance: 31.5%

#3647Medium

Maximum Weight in Two Bags

ArrayDynamic Programming

Acceptance: 58.3%

#3742Medium

Maximum Path Score in a Grid

ArrayDynamic ProgrammingMatrix

Acceptance: 53.7%

#3666Hard

Minimum Operations to Equalize Binary String

Breadth-First SearchMathOrdered Set+2

Acceptance: 45.2%

#3661Hard

Maximum Walls Destroyed by Robots

ArrayBinary SearchDynamic Programming+1

Acceptance: 48.0%

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

#3655Hard

XOR After Range Multiplication Queries II

ArrayDivide and Conquer

Acceptance: 47.8%

#3653Medium

XOR After Range Multiplication Queries I

ArrayDivide and ConquerSimulation

Acceptance: 73.3%

#3643Easy

Flip Square Submatrix Vertically

ArrayMatrixTwo Pointers

Acceptance: 79.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%

#3633Easy

Earliest Finish Time for Land and Water Rides I

ArrayBinary SearchGreedy+2

Acceptance: 73.0%

#3700Hard

Number of ZigZag Arrays II

Dynamic ProgrammingMath

Acceptance: 67.7%

#3649Medium

Number of Perfect Pairs

ArrayMathSorting+1

Acceptance: 34.2%

#3699Hard

Number of ZigZag Arrays I

Dynamic ProgrammingPrefix Sum

Acceptance: 50.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%

#3715Hard

Sum of Perfect Square Ancestors

ArrayCountingDepth-First Search+4

Acceptance: 41.3%

#3640Hard

Trionic Array II

ArrayDynamic Programming

Acceptance: 47.3%

#3636Hard

Threshold Majority Queries

ArrayBinary SearchCounting+3

Acceptance: 22.5%

#3638Medium

Maximum Balanced Shipments

ArrayDynamic ProgrammingGreedy+2

Acceptance: 61.4%

#3679Medium

Minimum Discards to Balance Inventory

ArrayCountingHash Table+2

Acceptance: 34.9%

#3637Easy

Trionic Array I

Array

Acceptance: 49.5%

#3646Hard

Next Special Palindrome Number

BacktrackingBit Manipulation

Acceptance: 28.0%

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