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

Convert Number Words to Digits

StringTrie

Acceptance: 67.7%

#3789Medium

Minimum Cost to Acquire Required Items

GreedyMath

Acceptance: 34.8%

#3771Medium

Total Score of Dungeon Runs

ArrayBinary SearchPrefix Sum

Acceptance: 30.6%

#3768Hard

Minimum Inversion Count in Subarrays of Fixed Length

ArraySegment TreeSliding Window

Acceptance: 40.3%

#3801Hard

Minimum Cost to Merge Sorted Lists

ArrayBinary SearchBit Manipulation+2

Acceptance: 33.2%

#3811Medium

Number of Alternating XOR Partitions

ArrayBit ManipulationDynamic Programming+1

Acceptance: 27.3%

#3759Medium

Count Elements With at Least K Greater Values

ArrayBinary SearchDivide and Conquer+2

Acceptance: 31.9%

#3749Hard

Evaluate Valid Expressions

Divide and ConquerHash TableMath+2

Acceptance: 69.4%

#3761Medium

Minimum Absolute Distance Between Mirror Pairs

ArrayHash TableMath

Acceptance: 59.1%

#3784Medium

Minimum Deletion Cost to Make All Characters Equal

ArrayEnumerationHash Table+1

Acceptance: 55.0%

#3839Medium

Number of Prefix Connected Groups

ArrayCountingHash Table+1

Acceptance: 60.5%

#3756Medium

Concatenate Non-Zero Digits and Multiply by Sum II

MathPrefix SumString

Acceptance: 42.7%

#3754Easy

Concatenate Non-Zero Digits and Multiply by Sum I

Math

Acceptance: 66.2%

#3757Hard

Number of Effective Subsequences

ArrayBit ManipulationCombinatorics+2

Acceptance: 32.4%

#3802Hard

Number of Ways to Paint Sheets

Acceptance: 67.3%

#3781Medium

Maximum Score After Binary Swaps

ArrayGreedyHeap (Priority Queue)+1

Acceptance: 35.0%

#3804Medium

Number of Centered Subarrays

ArrayEnumerationHash Table

Acceptance: 67.5%

#3753Hard

Total Waviness of Numbers in Range II

Dynamic ProgrammingMath

Acceptance: 56.2%

#3778Medium

Minimum Distance Excluding One Maximum Weighted Edge

Acceptance: 46.8%

#3750Easy

Minimum Number of Flips to Reverse Binary String

Bit ManipulationMathString+1

Acceptance: 76.7%

#3828Medium

Final Element After Subarray Deletions

ArrayBrainteaserGame Theory+1

Acceptance: 40.9%

#3826Hard

Minimum Partition Score

ArrayDivide and ConquerDynamic Programming+3

Acceptance: 32.6%

#3741Medium

Minimum Distance Between Three Equal Elements II

ArrayHash Table

Acceptance: 74.3%

#3829Medium

Design Ride Sharing System

Data StreamDesignHash Table+1

Acceptance: 62.6%

#3736Easy

Minimum Moves to Equal Array Elements III

ArrayMath

Acceptance: 81.0%

#3740Easy

Minimum Distance Between Three Equal Elements I

ArrayHash Table

Acceptance: 73.4%

#3744Medium

Find Kth Character in Expanded String

String

Acceptance: 55.8%

#3745Easy

Maximize Expression of Three Elements

ArrayEnumerationGreedy+1

Acceptance: 72.3%

#3748Hard

Count Stable Subarrays

ArrayBinary SearchPrefix Sum

Acceptance: 33.0%

#3730Medium

Maximum Calories Burnt from Jumps

ArrayGreedySorting+1

Acceptance: 72.2%

#3717Medium

Minimum Operations to Make the Array Beautiful

ArrayDynamic Programming

Acceptance: 37.5%

#3731Easy

Find Missing Elements

ArrayHash TableSorting

Acceptance: 88.6%

#3735Hard

Lexicographically Smallest String After Reverse II

Binary SearchHash FunctionRolling Hash+2

Acceptance: 48.3%

#3732Medium

Maximum Product of Three Elements After One Replacement

ArrayGreedyMath+1

Acceptance: 47.8%

#3765Medium

Complete Prime Number

EnumerationMathNumber Theory

Acceptance: 36.9%

#3766Medium

Minimum Operations to Make Binary Palindrome

ArrayBinary SearchBit Manipulation+1

Acceptance: 51.2%

#3738Medium

Longest Non-Decreasing Subarray After Replacing at Most One Element

ArrayDynamic Programming

Acceptance: 22.9%

#3877Medium

Minimum Removals to Achieve Target XOR

ArrayBit ManipulationDynamic Programming

Acceptance: 41.9%

#3791Hard

Number of Balanced Integers in a Range

Dynamic Programming

Acceptance: 36.3%

#3746Medium

Minimum String Length After Balanced Removals

CountingStackString

Acceptance: 77.6%

#3767Medium

Maximize Points After Choosing K Tasks

ArrayGreedyHeap (Priority Queue)+1

Acceptance: 59.1%

#3760Medium

Maximum Substrings With Distinct Start

Hash TableString

Acceptance: 91.4%

#3816Hard

Lexicographically Smallest String After Deleting Duplicate Characters

GreedyHash TableMonotonic Stack+2

Acceptance: 20.9%

#3770Medium

Largest Prime from Consecutive Prime Sum

ArrayMathNumber Theory

Acceptance: 39.0%

#3723Medium

Maximize Sum of Squares of Digits

GreedyMath

Acceptance: 57.9%

#3728Medium

Stable Subarrays With Equal Boundary and Interior Sum

ArrayHash TablePrefix Sum

Acceptance: 26.6%

#3711Medium

Maximum Transactions Without Negative Balance

ArrayGreedyHeap (Priority Queue)

Acceptance: 46.1%

#3718Easy

Smallest Missing Multiple of K

ArrayHash Table

Acceptance: 71.5%

#3814Medium

Maximum Capacity Within Budget

ArrayBinary SearchSorting+1

Acceptance: 20.7%

#3727Medium

Maximum Alternating Sum of Squares

ArrayGreedySorting

Acceptance: 61.3%

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