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

Flipping an Image

ArrayBit ManipulationMatrix+2

Acceptance: 83.6%

#836Easy

Rectangle Overlap

GeometryMath

Acceptance: 53.0%

#844Easy

Backspace String Compare

SimulationStackString+1

Acceptance: 49.9%

#859Easy

Buddy Strings

Hash TableString

Acceptance: 34.0%

#860Easy

Lemonade Change

ArrayGreedy

Acceptance: 59.0%

#867Easy

Transpose Matrix

ArrayMatrixSimulation

Acceptance: 76.8%

#868Easy

Binary Gap

Bit Manipulation

Acceptance: 74.2%

#872Easy

Leaf-Similar Trees

Binary TreeDepth-First SearchTree

Acceptance: 70.0%

#876Easy

Middle of the Linked List

Linked ListTwo Pointers

Acceptance: 82.3%

#883Easy

Projection Area of 3D Shapes

ArrayGeometryMath+1

Acceptance: 76.3%

#884Easy

Uncommon Words from Two Sentences

CountingHash TableString

Acceptance: 75.8%

#888Easy

Fair Candy Swap

ArrayBinary SearchHash Table+1

Acceptance: 65.3%

#892Easy

Surface Area of 3D Shapes

ArrayGeometryMath+1

Acceptance: 71.2%

#896Easy

Monotonic Array

Array

Acceptance: 62.3%

#897Easy

Increasing Order Search Tree

Binary Search TreeBinary TreeDepth-First Search+2

Acceptance: 79.1%

#905Easy

Sort Array By Parity

ArraySortingTwo Pointers

Acceptance: 76.2%

#908Easy

Smallest Range I

ArrayMath

Acceptance: 74.0%

#914Easy

X of a Kind in a Deck of Cards

ArrayCountingHash Table+2

Acceptance: 30.4%

#917Easy

Reverse Only Letters

StringTwo Pointers

Acceptance: 68.9%

#922Easy

Sort Array By Parity II

ArraySortingTwo Pointers

Acceptance: 71.4%

#925Easy

Long Pressed Name

StringTwo Pointers

Acceptance: 32.8%

#929Easy

Unique Email Addresses

ArrayHash TableString

Acceptance: 67.9%

#933Easy

Number of Recent Calls

Data StreamDesignQueue

Acceptance: 78.9%

#938Easy

Range Sum of BST

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 87.2%

#941Easy

Valid Mountain Array

Array

Acceptance: 35.7%

#942Easy

DI String Match

ArrayGreedyString+1

Acceptance: 81.0%

#944Easy

Delete Columns to Make Sorted

ArrayString

Acceptance: 78.1%

#953Easy

Verifying an Alien Dictionary

ArrayHash TableString

Acceptance: 55.9%

#961Easy

N-Repeated Element in Size 2N Array

ArrayHash Table

Acceptance: 79.9%

#965Easy

Univalued Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 72.9%

#976Easy

Largest Perimeter Triangle

ArrayGreedyMath+1

Acceptance: 62.1%

#977Easy

Squares of a Sorted Array

ArraySortingTwo Pointers

Acceptance: 73.7%

#989Easy

Add to Array-Form of Integer

ArrayMath

Acceptance: 45.6%

#993Easy

Cousins in Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 59.8%

#997Easy

Find the Town Judge

ArrayGraphHash Table

Acceptance: 50.6%

#999Easy

Available Captures for Rook

ArrayMatrixSimulation

Acceptance: 72.2%

#1002Easy

Find Common Characters

ArrayHash TableString

Acceptance: 74.6%

#1005Easy

Maximize Sum Of Array After K Negations

ArrayGreedySorting

Acceptance: 54.3%

#1009Easy

Complement of Base 10 Integer

Bit Manipulation

Acceptance: 63.3%

#1013Easy

Partition Array Into Three Parts With Equal Sum

ArrayGreedy

Acceptance: 42.6%

#1018Easy

Binary Prefix Divisible By 5

ArrayBit Manipulation

Acceptance: 53.5%

#1021Easy

Remove Outermost Parentheses

StackString

Acceptance: 87.5%

#1022Easy

Sum of Root To Leaf Binary Numbers

Binary TreeDepth-First SearchTree

Acceptance: 76.6%

#1025Easy

Divisor Game

BrainteaserDynamic ProgrammingGame Theory+1

Acceptance: 72.3%

#1030Easy

Matrix Cells in Distance Order

ArrayGeometryMath+2

Acceptance: 74.6%

#1037Easy

Valid Boomerang

ArrayGeometryMath

Acceptance: 39.9%

#1046Easy

Last Stone Weight

ArrayHeap (Priority Queue)

Acceptance: 66.4%

#1047Easy

Remove All Adjacent Duplicates In String

StackString

Acceptance: 73.6%

#1050Easy

Actors and Directors Who Cooperated At Least Three Times

Database

Acceptance: 70.3%

#1051Easy

Height Checker

ArrayCounting SortSorting

Acceptance: 81.6%

Page 5 of 20

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