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

Add Strings

MathSimulationString

Acceptance: 52.1%

#422Easy

Valid Word Square

ArrayMatrix

Acceptance: 42.9%

#434Easy

Number of Segments in a String

String

Acceptance: 37.6%

#441Easy

Arranging Coins

Binary SearchMath

Acceptance: 48.1%

#448Easy

Find All Numbers Disappeared in an Array

ArrayHash Table

Acceptance: 64.4%

#455Easy

Assign Cookies

ArrayGreedySorting+1

Acceptance: 55.4%

#459Easy

Repeated Substring Pattern

StringString Matching

Acceptance: 48.6%

#461Easy

Hamming Distance

Bit Manipulation

Acceptance: 76.7%

#463Easy

Island Perimeter

ArrayBreadth-First SearchDepth-First Search+1

Acceptance: 74.3%

#476Easy

Number Complement

Bit Manipulation

Acceptance: 70.3%

#482Easy

License Key Formatting

String

Acceptance: 46.4%

#485Easy

Max Consecutive Ones

Array

Acceptance: 66.0%

#492Easy

Construct the Rectangle

Math

Acceptance: 64.6%

#495Easy

Teemo Attacking

ArraySimulation

Acceptance: 57.6%

#496Easy

Next Greater Element I

ArrayHash TableMonotonic Stack+1

Acceptance: 76.5%

#500Easy

Keyboard Row

ArrayHash TableString

Acceptance: 74.3%

#501Easy

Find Mode in Binary Search Tree

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 59.2%

#504Easy

Base 7

Math

Acceptance: 55.3%

#506Easy

Relative Ranks

ArrayHeap (Priority Queue)Sorting

Acceptance: 75.1%

#507Easy

Perfect Number

Math

Acceptance: 50.0%

#509Easy

Fibonacci Number

Dynamic ProgrammingMathMemoization+1

Acceptance: 74.6%

#511Easy

Game Play Analysis I

Database

Acceptance: 75.1%

#512Easy

Game Play Analysis II

Database

Acceptance: 53.4%

#520Easy

Detect Capital

String

Acceptance: 56.8%

#521Easy

Longest Uncommon Subsequence I

String

Acceptance: 62.7%

#530Easy

Minimum Absolute Difference in BST

Binary Search TreeBinary TreeBreadth-First Search+2

Acceptance: 59.3%

#541Easy

Reverse String II

StringTwo Pointers

Acceptance: 54.1%

#543Easy

Diameter of Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 65.8%

#551Easy

Student Attendance Record I

String

Acceptance: 50.1%

#557Easy

Reverse Words in a String III

StringTwo Pointers

Acceptance: 84.0%

#559Easy

Maximum Depth of N-ary Tree

Breadth-First SearchDepth-First SearchTree

Acceptance: 73.5%

#561Easy

Array Partition

ArrayCounting SortGreedy+1

Acceptance: 82.2%

#563Easy

Binary Tree Tilt

Binary TreeDepth-First SearchTree

Acceptance: 66.2%

#566Easy

Reshape the Matrix

ArrayMatrixSimulation

Acceptance: 65.4%

#572Easy

Subtree of Another Tree

Binary TreeDepth-First SearchHash Function+2

Acceptance: 52.0%

#575Easy

Distribute Candies

ArrayHash Table

Acceptance: 71.5%

#577Easy

Employee Bonus

Database

Acceptance: 76.7%

#584Easy

Find Customer Referee

Database

Acceptance: 71.2%

#586Easy

Customer Placing the Largest Number of Orders

Database

Acceptance: 64.6%

#589Easy

N-ary Tree Preorder Traversal

Depth-First SearchStackTree

Acceptance: 76.7%

#590Easy

N-ary Tree Postorder Traversal

Depth-First SearchStackTree

Acceptance: 81.0%

#594Easy

Longest Harmonious Subsequence

ArrayCountingHash Table+2

Acceptance: 65.1%

#595Easy

Big Countries

Database

Acceptance: 68.2%

#596Easy

Classes More Than 5 Students

Database

Acceptance: 58.4%

#597Easy

Friend Requests I: Overall Acceptance Rate

Database

Acceptance: 41.6%

#598Easy

Range Addition II

ArrayMath

Acceptance: 59.1%

#599Easy

Minimum Index Sum of Two Lists

ArrayHash TableString

Acceptance: 60.2%

#603Easy

Consecutive Available Seats

Database

Acceptance: 65.7%

#604Easy

Design Compressed String Iterator

ArrayDesignIterator+1

Acceptance: 40.5%

#605Easy

Can Place Flowers

ArrayGreedy

Acceptance: 28.8%

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