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
#4Hard

Median of Two Sorted Arrays

ArrayBinary SearchDivide and Conquer

Acceptance: 47.3%

#10Hard

Regular Expression Matching

Dynamic ProgrammingRecursionString

Acceptance: 31.8%

#23Hard

Merge k Sorted Lists

Divide and ConquerHeap (Priority Queue)Linked List+1

Acceptance: 60.3%

#25Hard

Reverse Nodes in k-Group

Linked ListRecursion

Acceptance: 66.8%

#30Hard

Substring with Concatenation of All Words

Hash TableSliding WindowString

Acceptance: 34.8%

#32Hard

Longest Valid Parentheses

Dynamic ProgrammingStackString

Acceptance: 39.5%

#37Hard

Sudoku Solver

ArrayBacktrackingHash Table+1

Acceptance: 65.4%

#41Hard

First Missing Positive

ArrayHash Table

Acceptance: 43.8%

#42Hard

Trapping Rain Water

ArrayDynamic ProgrammingMonotonic Stack+2

Acceptance: 68.2%

#44Hard

Wildcard Matching

Dynamic ProgrammingGreedyRecursion+1

Acceptance: 32.8%

#51Hard

N-Queens

ArrayBacktracking

Acceptance: 76.3%

#52Hard

N-Queens II

Backtracking

Acceptance: 78.9%

#60Hard

Permutation Sequence

MathRecursion

Acceptance: 54.3%

#65Hard

Valid Number

String

Acceptance: 23.3%

#68Hard

Text Justification

ArraySimulationString

Acceptance: 51.8%

#76Hard

Minimum Window Substring

Hash TableSliding WindowString

Acceptance: 48.3%

#84Hard

Largest Rectangle in Histogram

ArrayMonotonic StackStack

Acceptance: 50.7%

#85Hard

Maximal Rectangle

ArrayDynamic ProgrammingMatrix+2

Acceptance: 59.5%

#87Hard

Scramble String

Dynamic ProgrammingString

Acceptance: 45.3%

#115Hard

Distinct Subsequences

Dynamic ProgrammingString

Acceptance: 54.1%

#123Hard

Best Time to Buy and Sell Stock III

ArrayDynamic Programming

Acceptance: 54.5%

#124Hard

Binary Tree Maximum Path Sum

Binary TreeDepth-First SearchDynamic Programming+1

Acceptance: 42.7%

#126Hard

Word Ladder II

BacktrackingBreadth-First SearchHash Table+1

Acceptance: 27.7%

#127Hard

Word Ladder

Breadth-First SearchHash TableString

Acceptance: 46.3%

#132Hard

Palindrome Partitioning II

Dynamic ProgrammingString

Acceptance: 37.9%

#135Hard

Candy

ArrayGreedy

Acceptance: 49.3%

#140Hard

Word Break II

ArrayBacktrackingDynamic Programming+4

Acceptance: 55.8%

#149Hard

Max Points on a Line

ArrayGeometryHash Table+1

Acceptance: 31.0%

#154Hard

Find Minimum in Rotated Sorted Array II

ArrayBinary Search

Acceptance: 46.6%

#158Hard

Read N Characters Given read4 II - Call Multiple Times

ArrayInteractiveSimulation

Acceptance: 43.2%

#174Hard

Dungeon Game

ArrayDynamic ProgrammingMatrix

Acceptance: 42.2%

#185Hard

Department Top Three Salaries

Database

Acceptance: 55.8%

#188Hard

Best Time to Buy and Sell Stock IV

ArrayDynamic Programming

Acceptance: 50.9%

#212Hard

Word Search II

ArrayBacktrackingMatrix+2

Acceptance: 38.8%

#214Hard

Shortest Palindrome

Hash FunctionRolling HashString+1

Acceptance: 42.7%

#218Hard

The Skyline Problem

ArrayBinary Indexed TreeDivide and Conquer+4

Acceptance: 45.7%

#220Hard

Contains Duplicate III

ArrayBucket SortOrdered Set+2

Acceptance: 25.2%

#224Hard

Basic Calculator

MathRecursionStack+1

Acceptance: 46.7%

#233Hard

Number of Digit One

Dynamic ProgrammingMathRecursion

Acceptance: 39.9%

#239Hard

Sliding Window Maximum

ArrayHeap (Priority Queue)Monotonic Queue+2

Acceptance: 49.1%

#248Hard

Strobogrammatic Number III

ArrayRecursionString

Acceptance: 42.3%

#262Hard

Trips and Users

Database

Acceptance: 36.7%

#265Hard

Paint House II

ArrayDynamic Programming

Acceptance: 57.0%

#269Hard

Alien Dictionary

ArrayBreadth-First SearchDepth-First Search+3

Acceptance: 37.1%

#272Hard

Closest Binary Search Tree Value II

Binary Search TreeBinary TreeDepth-First Search+4

Acceptance: 61.1%

#273Hard

Integer to English Words

MathRecursionString

Acceptance: 34.9%

#282Hard

Expression Add Operators

BacktrackingMathString

Acceptance: 43.5%

#295Hard

Find Median from Data Stream

Data StreamDesignHeap (Priority Queue)+2

Acceptance: 54.9%

#296Hard

Best Meeting Point

ArrayMathMatrix+1

Acceptance: 61.1%

#297Hard

Serialize and Deserialize Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+3

Acceptance: 61.1%

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