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

Design Tic-Tac-Toe

ArrayDesignHash Table+2

Acceptance: 58.8%

#351Medium

Android Unlock Patterns

BacktrackingBit ManipulationBitmask+1

Acceptance: 53.8%

#353Medium

Design Snake Game

ArrayDesignHash Table+2

Acceptance: 40.0%

#355Medium

Design Twitter

DesignHash TableHeap (Priority Queue)+1

Acceptance: 45.6%

#356Medium

Line Reflection

ArrayHash TableMath

Acceptance: 36.3%

#357Medium

Count Numbers with Unique Digits

BacktrackingDynamic ProgrammingMath

Acceptance: 56.1%

#360Medium

Sort Transformed Array

ArrayMathSorting+1

Acceptance: 58.0%

#361Medium

Bomb Enemy

ArrayDynamic ProgrammingMatrix

Acceptance: 52.8%

#362Medium

Design Hit Counter

ArrayBinary SearchData Stream+2

Acceptance: 69.6%

#364Medium

Nested List Weight Sum II

Breadth-First SearchDepth-First SearchStack

Acceptance: 66.8%

#365Medium

Water and Jug Problem

Breadth-First SearchDepth-First SearchMath

Acceptance: 46.4%

#366Medium

Find Leaves of Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 81.4%

#368Medium

Largest Divisible Subset

ArrayDynamic ProgrammingMath+1

Acceptance: 50.1%

#369Medium

Plus One Linked List

Linked ListMath

Acceptance: 61.1%

#370Medium

Range Addition

ArrayPrefix Sum

Acceptance: 73.0%

#371Medium

Sum of Two Integers

Bit ManipulationMath

Acceptance: 55.9%

#372Medium

Super Pow

Divide and ConquerMath

Acceptance: 37.3%

#373Medium

Find K Pairs with Smallest Sums

ArrayHeap (Priority Queue)

Acceptance: 42.3%

#375Medium

Guess Number Higher or Lower II

Dynamic ProgrammingGame TheoryMath

Acceptance: 53.2%

#376Medium

Wiggle Subsequence

ArrayDynamic ProgrammingGreedy

Acceptance: 49.3%

#377Medium

Combination Sum IV

ArrayDynamic Programming

Acceptance: 55.0%

#378Medium

Kth Smallest Element in a Sorted Matrix

ArrayBinary SearchHeap (Priority Queue)+2

Acceptance: 65.1%

#379Medium

Design Phone Directory

ArrayDesignHash Table+2

Acceptance: 52.7%

#380Medium

Insert Delete GetRandom O(1)

ArrayDesignHash Table+2

Acceptance: 55.3%

#382Medium

Linked List Random Node

Linked ListMathRandomized+1

Acceptance: 64.7%

#384Medium

Shuffle an Array

ArrayDesignMath+1

Acceptance: 59.6%

#385Medium

Mini Parser

Depth-First SearchStackString

Acceptance: 43.4%

#386Medium

Lexicographical Numbers

Depth-First SearchTrie

Acceptance: 76.2%

#388Medium

Longest Absolute File Path

Depth-First SearchStackString

Acceptance: 49.9%

#390Medium

Elimination Game

MathRecursion

Acceptance: 46.7%

#393Medium

UTF-8 Validation

ArrayBit Manipulation

Acceptance: 46.7%

#394Medium

Decode String

RecursionStackString

Acceptance: 63.0%

#395Medium

Longest Substring with At Least K Repeating Characters

Divide and ConquerHash TableSliding Window+1

Acceptance: 46.2%

#396Medium

Rotate Function

ArrayDynamic ProgrammingMath

Acceptance: 54.0%

#397Medium

Integer Replacement

Bit ManipulationDynamic ProgrammingGreedy+1

Acceptance: 37.9%

#398Medium

Random Pick Index

Hash TableMathRandomized+1

Acceptance: 65.0%

#399Medium

Evaluate Division

ArrayBreadth-First SearchDepth-First Search+4

Acceptance: 64.1%

#400Medium

Nth Digit

Binary SearchMath

Acceptance: 38.8%

#402Medium

Remove K Digits

GreedyMonotonic StackStack+1

Acceptance: 37.7%

#406Medium

Queue Reconstruction by Height

ArrayBinary Indexed TreeSegment Tree+1

Acceptance: 74.6%

#413Medium

Arithmetic Slices

ArrayDynamic ProgrammingSliding Window

Acceptance: 65.0%

#416Medium

Partition Equal Subset Sum

ArrayDynamic Programming

Acceptance: 49.9%

#417Medium

Pacific Atlantic Water Flow

ArrayBreadth-First SearchDepth-First Search+1

Acceptance: 61.3%

#418Medium

Sentence Screen Fitting

ArrayDynamic ProgrammingString

Acceptance: 36.3%

#419Medium

Battleships in a Board

ArrayDepth-First SearchMatrix

Acceptance: 77.4%

#421Medium

Maximum XOR of Two Numbers in an Array

ArrayBit ManipulationHash Table+1

Acceptance: 53.8%

#423Medium

Reconstruct Original Digits from English

Hash TableMathString

Acceptance: 52.8%

#424Medium

Longest Repeating Character Replacement

Hash TableSliding WindowString

Acceptance: 60.4%

#426Medium

Convert Binary Search Tree to Sorted Doubly Linked List

Binary Search TreeBinary TreeDepth-First Search+4

Acceptance: 65.2%

#427Medium

Construct Quad Tree

ArrayDivide and ConquerMatrix+1

Acceptance: 78.2%

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