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%

#2Medium

Add Two Numbers

Linked ListMathRecursion

Acceptance: 49.3%

#3Medium

Longest Substring Without Repeating Characters

Hash TableSliding WindowString

Acceptance: 39.9%

#4Hard

Median of Two Sorted Arrays

ArrayBinary SearchDivide and Conquer

Acceptance: 47.3%

#5Medium

Longest Palindromic Substring

Dynamic ProgrammingStringTwo Pointers

Acceptance: 38.7%

#6Medium

Zigzag Conversion

String

Acceptance: 54.9%

#7Medium

Reverse Integer

Math

Acceptance: 32.2%

#8Medium

String to Integer (atoi)

String

Acceptance: 21.4%

#9Easy

Palindrome Number

Math

Acceptance: 61.0%

#10Hard

Regular Expression Matching

Dynamic ProgrammingRecursionString

Acceptance: 31.8%

#11Medium

Container With Most Water

ArrayGreedyTwo Pointers

Acceptance: 60.9%

#12Medium

Integer to Roman

Hash TableMathString

Acceptance: 71.2%

#13Easy

Roman to Integer

Hash TableMathString

Acceptance: 67.0%

#14Easy

Longest Common Prefix

StringTrie

Acceptance: 48.0%

#15Medium

3Sum

ArraySortingTwo Pointers

Acceptance: 39.5%

#16Medium

3Sum Closest

ArraySortingTwo Pointers

Acceptance: 47.4%

#17Medium

Letter Combinations of a Phone Number

BacktrackingHash TableString

Acceptance: 66.9%

#18Medium

4Sum

ArraySortingTwo Pointers

Acceptance: 41.4%

#19Medium

Remove Nth Node From End of List

Linked ListTwo Pointers

Acceptance: 52.4%

#20Easy

Valid Parentheses

StackString

Acceptance: 44.5%

#21Easy

Merge Two Sorted Lists

Linked ListRecursion

Acceptance: 68.7%

#22Medium

Generate Parentheses

BacktrackingDynamic ProgrammingString

Acceptance: 79.0%

#23Hard

Merge k Sorted Lists

Divide and ConquerHeap (Priority Queue)Linked List+1

Acceptance: 60.3%

#24Medium

Swap Nodes in Pairs

Linked ListRecursion

Acceptance: 70.3%

#25Hard

Reverse Nodes in k-Group

Linked ListRecursion

Acceptance: 66.8%

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

#29Medium

Divide Two Integers

Bit ManipulationMath

Acceptance: 20.1%

#30Hard

Substring with Concatenation of All Words

Hash TableSliding WindowString

Acceptance: 34.8%

#31Medium

Next Permutation

ArrayTwo Pointers

Acceptance: 46.1%

#32Hard

Longest Valid Parentheses

Dynamic ProgrammingStackString

Acceptance: 39.5%

#33Medium

Search in Rotated Sorted Array

ArrayBinary Search

Acceptance: 45.5%

#34Medium

Find First and Last Position of Element in Sorted Array

ArrayBinary Search

Acceptance: 49.7%

#35Easy

Search Insert Position

ArrayBinary Search

Acceptance: 52.1%

#36Medium

Valid Sudoku

ArrayHash TableMatrix

Acceptance: 64.9%

#37Hard

Sudoku Solver

ArrayBacktrackingHash Table+1

Acceptance: 65.4%

#38Medium

Count and Say

String

Acceptance: 63.7%

#39Medium

Combination Sum

ArrayBacktracking

Acceptance: 76.9%

#40Medium

Combination Sum II

ArrayBacktracking

Acceptance: 59.7%

#41Hard

First Missing Positive

ArrayHash Table

Acceptance: 43.8%

#42Hard

Trapping Rain Water

ArrayDynamic ProgrammingMonotonic Stack+2

Acceptance: 68.2%

#43Medium

Multiply Strings

MathSimulationString

Acceptance: 44.4%

#44Hard

Wildcard Matching

Dynamic ProgrammingGreedyRecursion+1

Acceptance: 32.8%

#45Medium

Jump Game II

ArrayDynamic ProgrammingGreedy

Acceptance: 43.2%

#46Medium

Permutations

ArrayBacktracking

Acceptance: 82.3%

#47Medium

Permutations II

ArrayBacktracking

Acceptance: 63.7%

#48Medium

Rotate Image

ArrayMathMatrix

Acceptance: 80.7%

#49Medium

Group Anagrams

ArrayHash TableSorting+1

Acceptance: 73.0%

#50Medium

Pow(x, n)

MathRecursion

Acceptance: 39.0%

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