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

Minimum Cost to Connect Sticks

ArrayGreedyHeap (Priority Queue)

Acceptance: 71.8%

#1169Medium

Invalid Transactions

ArrayHash TableSorting+1

Acceptance: 32.1%

#1170Medium

Compare Strings by Frequency of the Smallest Character

ArrayBinary SearchHash Table+2

Acceptance: 63.3%

#1171Medium

Remove Zero Sum Consecutive Nodes from Linked List

Hash TableLinked List

Acceptance: 53.3%

#1174Medium

Immediate Food Delivery II

Database

Acceptance: 53.1%

#1177Medium

Can Make Palindrome from Substring

ArrayBit ManipulationHash Table+2

Acceptance: 42.0%

#1181Medium

Before and After Puzzle

ArrayHash TableSorting+1

Acceptance: 51.8%

#1182Medium

Shortest Distance to Target Color

ArrayBinary SearchDynamic Programming

Acceptance: 56.5%

#1186Medium

Maximum Subarray Sum with One Deletion

ArrayDynamic Programming

Acceptance: 49.4%

#1188Medium

Design Bounded Blocking Queue

Concurrency

Acceptance: 72.6%

#1190Medium

Reverse Substrings Between Each Pair of Parentheses

StackString

Acceptance: 71.8%

#1191Medium

K-Concatenation Maximum Sum

ArrayDynamic Programming

Acceptance: 25.9%

#1193Medium

Monthly Transactions I

Database

Acceptance: 58.3%

#1195Medium

Fizz Buzz Multithreaded

Concurrency

Acceptance: 73.2%

#1197Medium

Minimum Knight Moves

Breadth-First Search

Acceptance: 41.8%

#1198Medium

Find Smallest Common Element in All Rows

ArrayBinary SearchCounting+2

Acceptance: 76.5%

#1201Medium

Ugly Number III

Binary SearchCombinatoricsMath+1

Acceptance: 31.9%

#1202Medium

Smallest String With Swaps

ArrayBreadth-First SearchDepth-First Search+4

Acceptance: 61.0%

#1204Medium

Last Person to Fit in the Bus

Database

Acceptance: 68.0%

#1205Medium

Monthly Transactions II

Database

Acceptance: 41.8%

#1208Medium

Get Equal Substrings Within Budget

Binary SearchPrefix SumSliding Window+1

Acceptance: 60.2%

#1209Medium

Remove All Adjacent Duplicates in String II

StackString

Acceptance: 61.7%

#1212Medium

Team Scores in Football Tournament

Database

Acceptance: 55.6%

#1214Medium

Two Sum BSTs

Binary SearchBinary Search TreeBinary Tree+4

Acceptance: 68.2%

#1215Medium

Stepping Numbers

BacktrackingBreadth-First SearchMath

Acceptance: 48.2%

#1218Medium

Longest Arithmetic Subsequence of Given Difference

ArrayDynamic ProgrammingHash Table

Acceptance: 54.5%

#1219Medium

Path with Maximum Gold

ArrayBacktrackingMatrix

Acceptance: 68.6%

#1222Medium

Queens That Can Attack the King

ArrayMatrixSimulation

Acceptance: 72.6%

#1226Medium

The Dining Philosophers

Concurrency

Acceptance: 54.5%

#1227Medium

Airplane Seat Assignment Probability

BrainteaserDynamic ProgrammingMath+1

Acceptance: 67.3%

#1229Medium

Meeting Scheduler

ArraySortingTwo Pointers

Acceptance: 55.3%

#1230Medium

Toss Strange Coins

ArrayDynamic ProgrammingMath+1

Acceptance: 58.1%

#1233Medium

Remove Sub-Folders from the Filesystem

ArrayDepth-First SearchString+1

Acceptance: 78.6%

#1234Medium

Replace the Substring for Balanced String

Sliding WindowString

Acceptance: 41.3%

#1236Medium

Web Crawler

Breadth-First SearchDepth-First SearchInteractive+1

Acceptance: 68.8%

#1237Medium

Find Positive Integer Solution for a Given Equation

Binary SearchInteractiveMath+1

Acceptance: 69.7%

#1238Medium

Circular Permutation in Binary Representation

BacktrackingBit ManipulationMath

Acceptance: 72.6%

#1239Medium

Maximum Length of a Concatenated String with Unique Characters

ArrayBacktrackingBit Manipulation+1

Acceptance: 54.7%

#1242Medium

Web Crawler Multithreaded

Breadth-First SearchConcurrencyDepth-First Search

Acceptance: 49.5%

#1244Medium

Design A Leaderboard

DesignHash TableSorting

Acceptance: 67.9%

#1245Medium

Tree Diameter

Breadth-First SearchDepth-First SearchGraph+2

Acceptance: 61.1%

#1247Medium

Minimum Swaps to Make Strings Equal

GreedyMathString

Acceptance: 65.3%

#1248Medium

Count Number of Nice Subarrays

ArrayHash TableMath+2

Acceptance: 75.5%

#1249Medium

Minimum Remove to Make Valid Parentheses

StackString

Acceptance: 71.3%

#1253Medium

Reconstruct a 2-Row Binary Matrix

ArrayGreedyMatrix

Acceptance: 49.4%

#1254Medium

Number of Closed Islands

ArrayBreadth-First SearchDepth-First Search+2

Acceptance: 67.1%

#1256Medium

Encode Number

Bit ManipulationMathString

Acceptance: 70.0%

#1257Medium

Smallest Common Region

ArrayBreadth-First SearchDepth-First Search+3

Acceptance: 68.6%

#1258Medium

Synonymous Sentences

ArrayBacktrackingHash Table+2

Acceptance: 57.2%

#1261Medium

Find Elements in a Contaminated Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+3

Acceptance: 84.1%

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