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

Two Sum II - Input Array Is Sorted

ArrayBinary SearchTwo Pointers

Acceptance: 65.5%

#172Medium

Factorial Trailing Zeroes

Math

Acceptance: 46.9%

#173Medium

Binary Search Tree Iterator

Binary Search TreeBinary TreeDesign+3

Acceptance: 76.9%

#176Medium

Second Highest Salary

Database

Acceptance: 42.2%

#177Medium

Nth Highest Salary

Database

Acceptance: 38.0%

#178Medium

Rank Scores

Database

Acceptance: 63.9%

#179Medium

Largest Number

ArrayGreedySorting+1

Acceptance: 43.3%

#180Medium

Consecutive Numbers

Database

Acceptance: 44.6%

#184Medium

Department Highest Salary

Database

Acceptance: 53.2%

#186Medium

Reverse Words in a String II

StringTwo Pointers

Acceptance: 56.6%

#187Medium

Repeated DNA Sequences

Bit ManipulationHash FunctionHash Table+3

Acceptance: 53.7%

#189Medium

Rotate Array

ArrayMathTwo Pointers

Acceptance: 45.3%

#192Medium

Word Frequency

Shell

Acceptance: 26.3%

#194Medium

Transpose File

Shell

Acceptance: 27.1%

#198Medium

House Robber

ArrayDynamic Programming

Acceptance: 53.6%

#199Medium

Binary Tree Right Side View

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 70.9%

#200Medium

Number of Islands

ArrayBreadth-First SearchDepth-First Search+2

Acceptance: 65.2%

#201Medium

Bitwise AND of Numbers Range

Bit Manipulation

Acceptance: 48.8%

#204Medium

Count Primes

ArrayEnumerationMath+1

Acceptance: 36.4%

#207Medium

Course Schedule

Breadth-First SearchDepth-First SearchGraph+1

Acceptance: 52.2%

#208Medium

Implement Trie (Prefix Tree)

DesignHash TableString+1

Acceptance: 69.9%

#209Medium

Minimum Size Subarray Sum

ArrayBinary SearchPrefix Sum+1

Acceptance: 52.5%

#210Medium

Course Schedule II

Breadth-First SearchDepth-First SearchGraph+1

Acceptance: 56.3%

#211Medium

Design Add and Search Words Data Structure

Depth-First SearchDesignString+1

Acceptance: 48.9%

#213Medium

House Robber II

ArrayDynamic Programming

Acceptance: 45.3%

#215Medium

Kth Largest Element in an Array

ArrayDivide and ConquerHeap (Priority Queue)+2

Acceptance: 68.8%

#216Medium

Combination Sum III

ArrayBacktracking

Acceptance: 73.6%

#221Medium

Maximal Square

ArrayDynamic ProgrammingMatrix

Acceptance: 50.7%

#222Medium

Count Complete Tree Nodes

Binary SearchBinary TreeBit Manipulation+1

Acceptance: 72.6%

#223Medium

Rectangle Area

GeometryMath

Acceptance: 50.3%

#227Medium

Basic Calculator II

MathStackString

Acceptance: 46.7%

#229Medium

Majority Element II

ArrayCountingHash Table+1

Acceptance: 56.5%

#230Medium

Kth Smallest Element in a BST

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 77.2%

#235Medium

Lowest Common Ancestor of a Binary Search Tree

Binary Search TreeBinary TreeDepth-First Search+1

Acceptance: 71.4%

#236Medium

Lowest Common Ancestor of a Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 70.1%

#237Medium

Delete Node in a Linked List

Linked List

Acceptance: 84.3%

#238Medium

Product of Array Except Self

ArrayPrefix Sum

Acceptance: 69.3%

#240Medium

Search a 2D Matrix II

ArrayBinary SearchDivide and Conquer+1

Acceptance: 57.6%

#241Medium

Different Ways to Add Parentheses

Dynamic ProgrammingMathMemoization+2

Acceptance: 73.7%

#244Medium

Shortest Word Distance II

ArrayDesignHash Table+2

Acceptance: 62.8%

#245Medium

Shortest Word Distance III

ArrayString

Acceptance: 59.4%

#247Medium

Strobogrammatic Number II

ArrayRecursionString

Acceptance: 53.5%

#249Medium

Group Shifted Strings

ArrayHash TableString

Acceptance: 67.8%

#250Medium

Count Univalue Subtrees

Binary TreeDepth-First SearchTree

Acceptance: 57.5%

#251Medium

Flatten 2D Vector

ArrayDesignIterator+1

Acceptance: 50.5%

#253Medium

Meeting Rooms II

ArrayGreedyHeap (Priority Queue)+3

Acceptance: 52.6%

#254Medium

Factor Combinations

Backtracking

Acceptance: 50.5%

#255Medium

Verify Preorder Sequence in Binary Search Tree

ArrayBinary Search TreeBinary Tree+4

Acceptance: 51.7%

#256Medium

Paint House

ArrayDynamic Programming

Acceptance: 64.3%

#259Medium

3Sum Smaller

ArrayBinary SearchSorting+1

Acceptance: 51.4%

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