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

Two Sum

ArrayHash Table

Acceptance: 57.8%

#9Easy

Palindrome Number

Math

Acceptance: 61.0%

#13Easy

Roman to Integer

Hash TableMathString

Acceptance: 67.0%

#14Easy

Longest Common Prefix

StringTrie

Acceptance: 48.0%

#20Easy

Valid Parentheses

StackString

Acceptance: 44.5%

#21Easy

Merge Two Sorted Lists

Linked ListRecursion

Acceptance: 68.7%

#26Easy

Remove Duplicates from Sorted Array

ArrayTwo Pointers

Acceptance: 63.7%

#27Easy

Remove Element

ArrayTwo Pointers

Acceptance: 62.2%

#28Easy

Find the Index of the First Occurrence in a String

StringString MatchingTwo Pointers

Acceptance: 47.0%

#35Easy

Search Insert Position

ArrayBinary Search

Acceptance: 52.1%

#58Easy

Length of Last Word

String

Acceptance: 59.7%

#66Easy

Plus One

ArrayMath

Acceptance: 50.3%

#67Easy

Add Binary

Bit ManipulationMathSimulation+1

Acceptance: 58.4%

#69Easy

Sqrt(x)

Binary SearchMath

Acceptance: 42.2%

#70Easy

Climbing Stairs

Dynamic ProgrammingMathMemoization

Acceptance: 54.0%

#83Easy

Remove Duplicates from Sorted List

Linked List

Acceptance: 57.6%

#88Easy

Merge Sorted Array

ArraySortingTwo Pointers

Acceptance: 55.7%

#94Easy

Binary Tree Inorder Traversal

Binary TreeDepth-First SearchStack+1

Acceptance: 80.4%

#100Easy

Same Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 68.0%

#101Easy

Symmetric Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 61.5%

#104Easy

Maximum Depth of Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 78.6%

#108Easy

Convert Sorted Array to Binary Search Tree

ArrayBinary Search TreeBinary Tree+2

Acceptance: 75.9%

#110Easy

Balanced Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 59.2%

#111Easy

Minimum Depth of Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 53.7%

#112Easy

Path Sum

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 55.2%

#118Easy

Pascal's Triangle

ArrayDynamic Programming

Acceptance: 79.4%

#119Easy

Pascal's Triangle II

ArrayDynamic Programming

Acceptance: 67.8%

#121Easy

Best Time to Buy and Sell Stock

ArrayDynamic Programming

Acceptance: 57.1%

#125Easy

Valid Palindrome

StringTwo Pointers

Acceptance: 54.2%

#136Easy

Single Number

ArrayBit Manipulation

Acceptance: 78.1%

#141Easy

Linked List Cycle

Hash TableLinked ListTwo Pointers

Acceptance: 54.6%

#144Easy

Binary Tree Preorder Traversal

Binary TreeDepth-First SearchStack+1

Acceptance: 76.6%

#145Easy

Binary Tree Postorder Traversal

Binary TreeDepth-First SearchStack+1

Acceptance: 79.0%

#157Easy

Read N Characters Given Read4

ArrayInteractiveSimulation

Acceptance: 42.5%

#160Easy

Intersection of Two Linked Lists

Hash TableLinked ListTwo Pointers

Acceptance: 64.6%

#163Easy

Missing Ranges

Array

Acceptance: 35.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%

#175Easy

Combine Two Tables

Database

Acceptance: 77.1%

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

#190Easy

Reverse Bits

Bit ManipulationDivide and Conquer

Acceptance: 69.2%

#191Easy

Number of 1 Bits

Bit ManipulationDivide and Conquer

Acceptance: 77.1%

#193Easy

Valid Phone Numbers

Shell

Acceptance: 26.6%

#195Easy

Tenth Line

Shell

Acceptance: 33.8%

#196Easy

Delete Duplicate Emails

Database

Acceptance: 63.4%

#197Easy

Rising Temperature

Database

Acceptance: 49.3%

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