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

Project Employees III

Database

Acceptance: 76.8%

#1079Medium

Letter Tile Possibilities

BacktrackingCountingHash Table+1

Acceptance: 83.5%

#1080Medium

Insufficient Nodes in Root to Leaf Paths

Binary TreeDepth-First SearchTree

Acceptance: 55.6%

#1081Medium

Smallest Subsequence of Distinct Characters

GreedyMonotonic StackStack+1

Acceptance: 70.6%

#1087Medium

Brace Expansion

BacktrackingBreadth-First SearchString

Acceptance: 66.5%

#1090Medium

Largest Values From Labels

ArrayCountingGreedy+2

Acceptance: 64.7%

#1091Medium

Shortest Path in Binary Matrix

ArrayBreadth-First SearchMatrix

Acceptance: 51.8%

#1093Medium

Statistics from a Large Sample

ArrayMathProbability and Statistics

Acceptance: 43.6%

#1094Medium

Car Pooling

ArrayHeap (Priority Queue)Prefix Sum+2

Acceptance: 56.5%

#1098Medium

Unpopular Books

Database

Acceptance: 43.3%

#1100Medium

Find K-Length Substrings With No Repeated Characters

Hash TableSliding WindowString

Acceptance: 76.5%

#1101Medium

The Earliest Moment When Everyone Become Friends

ArraySortingUnion Find

Acceptance: 66.0%

#1102Medium

Path With Maximum Minimum Value

ArrayBinary SearchBreadth-First Search+4

Acceptance: 54.6%

#1104Medium

Path In Zigzag Labelled Binary Tree

Binary TreeMathTree

Acceptance: 75.9%

#1105Medium

Filling Bookcase Shelves

ArrayDynamic Programming

Acceptance: 68.7%

#1107Medium

New Users Daily Count

Database

Acceptance: 44.7%

#1109Medium

Corporate Flight Bookings

ArrayPrefix Sum

Acceptance: 68.7%

#1110Medium

Delete Nodes And Return Forest

ArrayBinary TreeDepth-First Search+2

Acceptance: 72.4%

#1111Medium

Maximum Nesting Depth of Two Valid Parentheses Strings

StackString

Acceptance: 72.1%

#1112Medium

Highest Grade For Each Student

Database

Acceptance: 70.8%

#1115Medium

Print FooBar Alternately

Concurrency

Acceptance: 67.7%

#1116Medium

Print Zero Even Odd

Concurrency

Acceptance: 62.0%

#1117Medium

Building H2O

Concurrency

Acceptance: 57.1%

#1120Medium

Maximum Average Subtree

Binary TreeDepth-First SearchTree

Acceptance: 66.7%

#1123Medium

Lowest Common Ancestor of Deepest Leaves

Binary TreeBreadth-First SearchDepth-First Search+2

Acceptance: 79.5%

#1124Medium

Longest Well-Performing Interval

ArrayHash TableMonotonic Stack+2

Acceptance: 37.9%

#1126Medium

Active Businesses

Database

Acceptance: 65.8%

#1129Medium

Shortest Path with Alternating Colors

Breadth-First SearchGraph

Acceptance: 47.8%

#1130Medium

Minimum Cost Tree From Leaf Values

ArrayDynamic ProgrammingGreedy+2

Acceptance: 67.7%

#1131Medium

Maximum of Absolute Value Expression

ArrayMath

Acceptance: 48.4%

#1132Medium

Reported Posts II

Database

Acceptance: 32.3%

#1135Medium

Connecting Cities With Minimum Cost

GraphHeap (Priority Queue)Minimum Spanning Tree+1

Acceptance: 63.5%

#1136Medium

Parallel Courses

GraphTopological Sort

Acceptance: 62.1%

#1138Medium

Alphabet Board Path

Hash TableString

Acceptance: 51.5%

#1139Medium

Largest 1-Bordered Square

ArrayDynamic ProgrammingMatrix

Acceptance: 52.1%

#1140Medium

Stone Game II

ArrayDynamic ProgrammingGame Theory+2

Acceptance: 75.8%

#1143Medium

Longest Common Subsequence

Dynamic ProgrammingString

Acceptance: 59.6%

#1144Medium

Decrease Elements To Make Array Zigzag

ArrayGreedy

Acceptance: 49.7%

#1145Medium

Binary Tree Coloring Game

Binary TreeDepth-First SearchTree

Acceptance: 52.9%

#1146Medium

Snapshot Array

ArrayBinary SearchDesign+1

Acceptance: 36.8%

#1149Medium

Article Views II

Database

Acceptance: 47.1%

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

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

#1158Medium

Market Analysis I

Database

Acceptance: 57.2%

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

#1164Medium

Product Price at a Given Date

Database

Acceptance: 57.0%

#1166Medium

Design File System

DesignHash TableString+1

Acceptance: 65.1%

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