Skip to main content

Solutions & Explanations

Browse 4,030+ detailed solutions with multiple approaches, code in Python, Java, C++ and more.

4,030 Solutions961 Easy2102 Medium967 Hard
#1151Medium

Minimum Swaps to Group All 1's Together

ArraySliding Window

Acceptance: 61.2%

#1152Medium

Analyze User Website Visit Pattern

ArrayHash TableSorting

Acceptance: 44.3%

#1153Hard

String Transforms Into Another String

Hash TableString

Acceptance: 34.9%

#1154Easy

Day of the Year

MathString

Acceptance: 50.3%

#1155Medium

Number of Dice Rolls With Target Sum

Dynamic Programming

Acceptance: 62.2%

#1156Medium

Swap For Longest Repeated Character Substring

Hash TableSliding WindowString

Acceptance: 44.9%

#1157Hard

Online Majority Element In Subarray

ArrayBinary Indexed TreeBinary Search+2

Acceptance: 40.9%

#1158Medium

Market Analysis I

Database

Acceptance: 57.2%

#1159Hard

Market Analysis II

Database

Acceptance: 57.4%

#1160Easy

Find Words That Can Be Formed by Characters

ArrayCountingHash Table+1

Acceptance: 71.5%

#1161Medium

Maximum Level Sum of a Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 70.0%

#1162Medium

As Far from Land as Possible

ArrayBreadth-First SearchDynamic Programming+1

Acceptance: 52.2%

#1163Hard

Last Substring in Lexicographical Order

StringTwo Pointers

Acceptance: 35.1%

#1164Medium

Product Price at a Given Date

Database

Acceptance: 57.0%

#1165Easy

Single-Row Keyboard

Hash TableString

Acceptance: 87.6%

#1166Medium

Design File System

DesignHash TableString+1

Acceptance: 65.1%

#1167Medium

Minimum Cost to Connect Sticks

ArrayGreedyHeap (Priority Queue)

Acceptance: 71.8%

#1168Hard

Optimize Water Distribution in a Village

GraphHeap (Priority Queue)Minimum Spanning Tree+1

Acceptance: 65.5%

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

#1172Hard

Dinner Plate Stacks

DesignHash TableHeap (Priority Queue)+1

Acceptance: 33.6%

#1173Easy

Immediate Food Delivery I

Database

Acceptance: 80.9%

#1174Medium

Immediate Food Delivery II

Database

Acceptance: 53.1%

#1175Easy

Prime Arrangements

Math

Acceptance: 63.3%

#1176Easy

Diet Plan Performance

ArraySliding Window

Acceptance: 55.9%

#1177Medium

Can Make Palindrome from Substring

ArrayBit ManipulationHash Table+2

Acceptance: 42.0%

#1178Hard

Number of Valid Words for Each Puzzle

ArrayBit ManipulationHash Table+2

Acceptance: 47.8%

#1179Easy

Reformat Department Table

Database

Acceptance: 76.9%

#1180Easy

Count Substrings with Only One Distinct Letter

MathString

Acceptance: 80.9%

#1181Medium

Before and After Puzzle

ArrayHash TableSorting+1

Acceptance: 51.8%

#1182Medium

Shortest Distance to Target Color

ArrayBinary SearchDynamic Programming

Acceptance: 56.5%

#1183Hard

Maximum Number of Ones

GreedyHeap (Priority Queue)

Acceptance: 70.6%

#1184Easy

Distance Between Bus Stops

Array

Acceptance: 56.7%

#1185Easy

Day of the Week

Math

Acceptance: 59.6%

#1186Medium

Maximum Subarray Sum with One Deletion

ArrayDynamic Programming

Acceptance: 49.4%

#1187Hard

Make Array Strictly Increasing

ArrayBinary SearchDynamic Programming+1

Acceptance: 58.0%

#1188Medium

Design Bounded Blocking Queue

Concurrency

Acceptance: 72.6%

#1189Easy

Maximum Number of Balloons

CountingHash TableString

Acceptance: 64.1%

#1190Medium

Reverse Substrings Between Each Pair of Parentheses

StackString

Acceptance: 71.8%

#1191Medium

K-Concatenation Maximum Sum

ArrayDynamic Programming

Acceptance: 25.9%

#1192Hard

Critical Connections in a Network

Biconnected ComponentDepth-First SearchGraph

Acceptance: 60.6%

#1193Medium

Monthly Transactions I

Database

Acceptance: 58.3%

#1194Hard

Tournament Winners

Database

Acceptance: 49.3%

#1195Medium

Fizz Buzz Multithreaded

Concurrency

Acceptance: 73.2%

#1196Easy

How Many Apples Can You Put into the Basket

ArrayGreedySorting

Acceptance: 67.0%

#1197Medium

Minimum Knight Moves

Breadth-First Search

Acceptance: 41.8%

#1198Medium

Find Smallest Common Element in All Rows

ArrayBinary SearchCounting+2

Acceptance: 76.5%

#1199Hard

Minimum Time to Build Blocks

ArrayGreedyHeap (Priority Queue)+1

Acceptance: 49.2%

#1200Easy

Minimum Absolute Difference

ArraySorting

Acceptance: 75.1%

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