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

Find Mode in Binary Search Tree

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 59.2%

#502Hard

IPO

ArrayGreedyHeap (Priority Queue)+1

Acceptance: 53.6%

#503Medium

Next Greater Element II

ArrayMonotonic StackStack

Acceptance: 68.7%

#504Easy

Base 7

Math

Acceptance: 55.3%

#505Medium

The Maze II

ArrayBreadth-First SearchDepth-First Search+4

Acceptance: 55.0%

#506Easy

Relative Ranks

ArrayHeap (Priority Queue)Sorting

Acceptance: 75.1%

#507Easy

Perfect Number

Math

Acceptance: 50.0%

#508Medium

Most Frequent Subtree Sum

Binary TreeDepth-First SearchHash Table+1

Acceptance: 69.6%

#509Easy

Fibonacci Number

Dynamic ProgrammingMathMemoization+1

Acceptance: 74.6%

#510Medium

Inorder Successor in BST II

Binary Search TreeBinary TreeTree

Acceptance: 60.9%

#511Easy

Game Play Analysis I

Database

Acceptance: 75.1%

#512Easy

Game Play Analysis II

Database

Acceptance: 53.4%

#513Medium

Find Bottom Left Tree Value

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 72.2%

#514Hard

Freedom Trail

Breadth-First SearchDepth-First SearchDynamic Programming+1

Acceptance: 59.4%

#515Medium

Find Largest Value in Each Tree Row

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 66.3%

#516Medium

Longest Palindromic Subsequence

Dynamic ProgrammingString

Acceptance: 65.8%

#517Hard

Super Washing Machines

ArrayGreedy

Acceptance: 45.3%

#518Medium

Coin Change II

ArrayDynamic Programming

Acceptance: 59.7%

#519Medium

Random Flip Matrix

Hash TableMathRandomized+1

Acceptance: 46.9%

#520Easy

Detect Capital

String

Acceptance: 56.8%

#521Easy

Longest Uncommon Subsequence I

String

Acceptance: 62.7%

#522Medium

Longest Uncommon Subsequence II

ArrayHash TableSorting+2

Acceptance: 45.2%

#523Medium

Continuous Subarray Sum

ArrayHash TableMath+1

Acceptance: 31.3%

#524Medium

Longest Word in Dictionary through Deleting

ArraySortingString+1

Acceptance: 52.6%

#525Medium

Contiguous Array

ArrayHash TablePrefix Sum

Acceptance: 52.2%

#526Medium

Beautiful Arrangement

ArrayBacktrackingBit Manipulation+2

Acceptance: 64.9%

#527Hard

Word Abbreviation

ArrayGreedySorting+2

Acceptance: 62.7%

#528Medium

Random Pick with Weight

ArrayBinary SearchMath+2

Acceptance: 49.0%

#529Medium

Minesweeper

ArrayBreadth-First SearchDepth-First Search+1

Acceptance: 68.7%

#530Easy

Minimum Absolute Difference in BST

Binary Search TreeBinary TreeBreadth-First Search+2

Acceptance: 59.3%

#531Medium

Lonely Pixel I

ArrayHash TableMatrix

Acceptance: 62.3%

#532Medium

K-diff Pairs in an Array

ArrayBinary SearchHash Table+2

Acceptance: 46.3%

#533Medium

Lonely Pixel II

ArrayHash TableMatrix

Acceptance: 48.7%

#534Medium

Game Play Analysis III

Database

Acceptance: 81.0%

#535Medium

Encode and Decode TinyURL

DesignHash FunctionHash Table+1

Acceptance: 86.5%

#536Medium

Construct Binary Tree from String

Binary TreeDepth-First SearchStack+2

Acceptance: 58.7%

#537Medium

Complex Number Multiplication

MathSimulationString

Acceptance: 73.3%

#538Medium

Convert BST to Greater Tree

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 71.5%

#539Medium

Minimum Time Difference

ArrayMathSorting+1

Acceptance: 62.7%

#540Medium

Single Element in a Sorted Array

ArrayBinary Search

Acceptance: 59.3%

#541Easy

Reverse String II

StringTwo Pointers

Acceptance: 54.1%

#542Medium

01 Matrix

ArrayBreadth-First SearchDynamic Programming+1

Acceptance: 54.7%

#543Easy

Diameter of Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 65.8%

#544Medium

Output Contest Matches

RecursionSimulationString

Acceptance: 77.3%

#545Medium

Boundary of Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 48.0%

#546Hard

Remove Boxes

ArrayDynamic ProgrammingMemoization

Acceptance: 49.4%

#547Medium

Number of Provinces

Breadth-First SearchDepth-First SearchGraph+1

Acceptance: 70.8%

#548Hard

Split Array with Equal Sum

ArrayHash TablePrefix Sum

Acceptance: 50.1%

#549Medium

Binary Tree Longest Consecutive Sequence II

Binary TreeDepth-First SearchTree

Acceptance: 50.1%

#550Medium

Game Play Analysis IV

Database

Acceptance: 38.4%

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