Skip to main content

Solutions & Explanations

Browse 4,030+ detailed solutions with multiple approaches, code in Python, Java, C++ and more.

4,030 Solutions961 Easy2102 Medium967 Hard
#1301Hard

Number of Paths with Max Score

ArrayDynamic ProgrammingMatrix

Acceptance: 63.4%

#1302Medium

Deepest Leaves Sum

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 86.3%

#1303Easy

Find the Team Size

Database

Acceptance: 89.6%

#1304Easy

Find N Unique Integers Sum up to Zero

ArrayMath

Acceptance: 78.5%

#1305Medium

All Elements in Two Binary Search Trees

Binary Search TreeBinary TreeDepth-First Search+2

Acceptance: 79.9%

#1306Medium

Jump Game III

ArrayBreadth-First SearchDepth-First Search

Acceptance: 70.1%

#1307Hard

Verbal Arithmetic Puzzle

ArrayBacktrackingMath+1

Acceptance: 33.5%

#1308Medium

Running Total for Different Genders

Database

Acceptance: 86.3%

#1309Easy

Decrypt String from Alphabet to Integer Mapping

String

Acceptance: 80.6%

#1310Medium

XOR Queries of a Subarray

ArrayBit ManipulationPrefix Sum

Acceptance: 78.1%

#1311Medium

Get Watched Videos by Your Friends

ArrayBreadth-First SearchGraph+2

Acceptance: 54.2%

#1312Hard

Minimum Insertion Steps to Make a String Palindrome

Dynamic ProgrammingString

Acceptance: 74.3%

#1313Easy

Decompress Run-Length Encoded List

Array

Acceptance: 85.9%

#1314Medium

Matrix Block Sum

ArrayMatrixPrefix Sum

Acceptance: 77.0%

#1315Medium

Sum of Nodes with Even-Valued Grandparent

Binary TreeBreadth-First SearchDepth-First Search+1

Acceptance: 85.6%

#1316Hard

Distinct Echo Substrings

Hash FunctionRolling HashString+1

Acceptance: 53.7%

#1317Easy

Convert Integer to the Sum of Two No-Zero Integers

Math

Acceptance: 59.1%

#1318Medium

Minimum Flips to Make a OR b Equal to c

Bit Manipulation

Acceptance: 71.9%

#1319Medium

Number of Operations to Make Network Connected

Breadth-First SearchDepth-First SearchGraph+1

Acceptance: 67.0%

#1320Hard

Minimum Distance to Type a Word Using Two Fingers

Dynamic ProgrammingString

Acceptance: 72.2%

#1321Medium

Restaurant Growth

Database

Acceptance: 54.4%

#1322Easy

Ads Performance

Database

Acceptance: 59.4%

#1323Easy

Maximum 69 Number

GreedyMath

Acceptance: 84.5%

#1324Medium

Print Words Vertically

ArraySimulationString

Acceptance: 68.1%

#1325Medium

Delete Leaves With a Given Value

Binary TreeDepth-First SearchTree

Acceptance: 77.4%

#1326Hard

Minimum Number of Taps to Open to Water a Garden

ArrayDynamic ProgrammingGreedy

Acceptance: 50.7%

#1327Easy

List the Products Ordered in a Period

Database

Acceptance: 71.6%

#1328Medium

Break a Palindrome

GreedyString

Acceptance: 51.6%

#1329Medium

Sort the Matrix Diagonally

ArrayMatrixSorting

Acceptance: 82.9%

#1330Hard

Reverse Subarray To Maximize Array Value

ArrayGreedyMath

Acceptance: 44.1%

#1331Easy

Rank Transform of an Array

ArrayHash TableSorting

Acceptance: 73.9%

#1332Easy

Remove Palindromic Subsequences

StringTwo Pointers

Acceptance: 77.1%

#1333Medium

Filter Restaurants by Vegan-Friendly, Price and Distance

ArraySorting

Acceptance: 64.2%

#1334Medium

Find the City With the Smallest Number of Neighbors at a Threshold Distance

Dynamic ProgrammingGraphShortest Path

Acceptance: 73.5%

#1335Hard

Minimum Difficulty of a Job Schedule

ArrayDynamic Programming

Acceptance: 59.6%

#1336Hard

Number of Transactions per Visit

Database

Acceptance: 47.7%

#1337Easy

The K Weakest Rows in a Matrix

ArrayBinary SearchHeap (Priority Queue)+2

Acceptance: 74.3%

#1338Medium

Reduce Array Size to The Half

ArrayGreedyHash Table+2

Acceptance: 69.5%

#1339Medium

Maximum Product of Splitted Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 55.7%

#1340Hard

Jump Game V

ArrayDynamic ProgrammingSorting

Acceptance: 75.7%

#1341Medium

Movie Rating

Database

Acceptance: 40.8%

#1342Easy

Number of Steps to Reduce a Number to Zero

Bit ManipulationMath

Acceptance: 85.4%

#1343Medium

Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold

ArraySliding Window

Acceptance: 74.3%

#1344Medium

Angle Between Hands of a Clock

Math

Acceptance: 69.6%

#1345Hard

Jump Game IV

ArrayBreadth-First SearchHash Table

Acceptance: 50.9%

#1346Easy

Check If N and Its Double Exist

ArrayBinary SearchHash Table+2

Acceptance: 41.7%

#1347Medium

Minimum Number of Steps to Make Two Strings Anagram

CountingHash TableString

Acceptance: 82.6%

#1348Medium

Tweet Counts Per Frequency

Binary SearchDesignHash Table+2

Acceptance: 46.6%

#1349Hard

Maximum Students Taking Exam

ArrayBit ManipulationBitmask+2

Acceptance: 54.2%

#1350Easy

Students With Invalid Departments

Database

Acceptance: 89.8%

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