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

Reverse Words in a String

StringTwo Pointers

Acceptance: 57.8%

#152Medium

Maximum Product Subarray

ArrayDynamic Programming

Acceptance: 36.7%

#153Medium

Find Minimum in Rotated Sorted Array

ArrayBinary Search

Acceptance: 55.3%

#154Hard

Find Minimum in Rotated Sorted Array II

ArrayBinary Search

Acceptance: 46.6%

#155Medium

Min Stack

DesignStack

Acceptance: 58.5%

#156Medium

Binary Tree Upside Down

Binary TreeDepth-First SearchTree

Acceptance: 65.4%

#157Easy

Read N Characters Given Read4

ArrayInteractiveSimulation

Acceptance: 42.5%

#158Hard

Read N Characters Given read4 II - Call Multiple Times

ArrayInteractiveSimulation

Acceptance: 43.2%

#159Medium

Longest Substring with At Most Two Distinct Characters

Hash TableSliding WindowString

Acceptance: 57.0%

#160Easy

Intersection of Two Linked Lists

Hash TableLinked ListTwo Pointers

Acceptance: 64.6%

#161Medium

One Edit Distance

StringTwo Pointers

Acceptance: 34.4%

#162Medium

Find Peak Element

ArrayBinary Search

Acceptance: 46.8%

#163Easy

Missing Ranges

Array

Acceptance: 35.5%

#164Medium

Maximum Gap

ArrayBucket SortRadix Sort+1

Acceptance: 52.8%

#165Medium

Compare Version Numbers

StringTwo Pointers

Acceptance: 46.8%

#166Medium

Fraction to Recurring Decimal

Hash TableMathString

Acceptance: 31.3%

#167Medium

Two Sum II - Input Array Is Sorted

ArrayBinary SearchTwo Pointers

Acceptance: 65.5%

#168Easy

Excel Sheet Column Title

MathString

Acceptance: 47.3%

#169Easy

Majority Element

ArrayCountingDivide and Conquer+2

Acceptance: 66.2%

#170Easy

Two Sum III - Data structure design

ArrayData StreamDesign+2

Acceptance: 39.1%

#171Easy

Excel Sheet Column Number

MathString

Acceptance: 68.0%

#172Medium

Factorial Trailing Zeroes

Math

Acceptance: 46.9%

#173Medium

Binary Search Tree Iterator

Binary Search TreeBinary TreeDesign+3

Acceptance: 76.9%

#174Hard

Dungeon Game

ArrayDynamic ProgrammingMatrix

Acceptance: 42.2%

#175Easy

Combine Two Tables

Database

Acceptance: 77.1%

#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%

#181Easy

Employees Earning More Than Their Managers

Database

Acceptance: 70.6%

#182Easy

Duplicate Emails

Database

Acceptance: 71.8%

#183Easy

Customers Who Never Order

Database

Acceptance: 69.9%

#184Medium

Department Highest Salary

Database

Acceptance: 53.2%

#185Hard

Department Top Three Salaries

Database

Acceptance: 55.8%

#186Medium

Reverse Words in a String II

StringTwo Pointers

Acceptance: 56.6%

#187Medium

Repeated DNA Sequences

Bit ManipulationHash FunctionHash Table+3

Acceptance: 53.7%

#188Hard

Best Time to Buy and Sell Stock IV

ArrayDynamic Programming

Acceptance: 50.9%

#189Medium

Rotate Array

ArrayMathTwo Pointers

Acceptance: 45.3%

#190Easy

Reverse Bits

Bit ManipulationDivide and Conquer

Acceptance: 69.2%

#191Easy

Number of 1 Bits

Bit ManipulationDivide and Conquer

Acceptance: 77.1%

#192Medium

Word Frequency

Shell

Acceptance: 26.3%

#193Easy

Valid Phone Numbers

Shell

Acceptance: 26.6%

#194Medium

Transpose File

Shell

Acceptance: 27.1%

#195Easy

Tenth Line

Shell

Acceptance: 33.8%

#196Easy

Delete Duplicate Emails

Database

Acceptance: 63.4%

#197Easy

Rising Temperature

Database

Acceptance: 49.3%

#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%

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