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

Ways to Make a Fair Array

ArrayPrefix Sum

Acceptance: 67.2%

#1666Medium

Change the Root of a Binary Tree

Binary TreeDepth-First SearchTree

Acceptance: 74.4%

#1669Medium

Merge In Between Linked Lists

Linked List

Acceptance: 82.9%

#1670Medium

Design Front Middle Back Queue

ArrayData StreamDesign+2

Acceptance: 58.5%

#1673Medium

Find the Most Competitive Subsequence

ArrayGreedyMonotonic Stack+1

Acceptance: 53.4%

#1674Medium

Minimum Moves to Make Array Complementary

ArrayHash TablePrefix Sum

Acceptance: 65.2%

#1676Medium

Lowest Common Ancestor of a Binary Tree IV

Binary TreeDepth-First SearchHash Table+1

Acceptance: 79.6%

#1679Medium

Max Number of K-Sum Pairs

ArrayHash TableSorting+1

Acceptance: 56.9%

#1680Medium

Concatenation of Consecutive Binary Numbers

Bit ManipulationMathSimulation

Acceptance: 66.6%

#1682Medium

Longest Palindromic Subsequence II

Dynamic ProgrammingString

Acceptance: 50.1%

#1685Medium

Sum of Absolute Differences in a Sorted Array

ArrayMathPrefix Sum

Acceptance: 68.2%

#1686Medium

Stone Game VI

ArrayGame TheoryGreedy+3

Acceptance: 61.4%

#1689Medium

Partitioning Into Minimum Number Of Deci-Binary Numbers

GreedyString

Acceptance: 90.5%

#1690Medium

Stone Game VII

ArrayDynamic ProgrammingGame Theory+1

Acceptance: 59.4%

#1695Medium

Maximum Erasure Value

ArrayHash TableSliding Window

Acceptance: 64.2%

#1696Medium

Jump Game VI

ArrayDynamic ProgrammingHeap (Priority Queue)+2

Acceptance: 46.4%

#1698Medium

Number of Distinct Substrings in a String

Hash FunctionRolling HashString+2

Acceptance: 64.4%

#1699Medium

Number of Calls Between Two Persons

Database

Acceptance: 81.1%

#1701Medium

Average Waiting Time

ArraySimulation

Acceptance: 73.1%

#1702Medium

Maximum Binary String After Change

GreedyString

Acceptance: 48.1%

#1705Medium

Maximum Number of Eaten Apples

ArrayGreedyHeap (Priority Queue)

Acceptance: 44.2%

#1706Medium

Where Will the Ball Fall

ArrayMatrixSimulation

Acceptance: 71.9%

#1709Medium

Biggest Window Between Visits

Database

Acceptance: 70.3%

#1711Medium

Count Good Meals

ArrayHash Table

Acceptance: 32.7%

#1712Medium

Ways to Split Array Into Three Subarrays

ArrayBinary SearchPrefix Sum+1

Acceptance: 34.2%

#1715Medium

Count Apples and Oranges

Database

Acceptance: 75.6%

#1717Medium

Maximum Score From Removing Substrings

GreedyStackString

Acceptance: 66.6%

#1718Medium

Construct the Lexicographically Largest Valid Sequence

ArrayBacktracking

Acceptance: 72.7%

#1721Medium

Swapping Nodes in a Linked List

Linked ListTwo Pointers

Acceptance: 69.3%

#1722Medium

Minimize Hamming Distance After Swap Operations

ArrayDepth-First SearchUnion Find

Acceptance: 69.6%

#1726Medium

Tuple with Same Product

ArrayCountingHash Table

Acceptance: 70.1%

#1727Medium

Largest Submatrix With Rearrangements

ArrayGreedyMatrix+1

Acceptance: 80.3%

#1730Medium

Shortest Path to Get Food

ArrayBreadth-First SearchMatrix

Acceptance: 57.1%

#1733Medium

Minimum Number of People to Teach

ArrayGreedyHash Table

Acceptance: 67.7%

#1734Medium

Decode XORed Permutation

ArrayBit Manipulation

Acceptance: 67.0%

#1737Medium

Change Minimum Characters to Satisfy One of Three Conditions

CountingHash TablePrefix Sum+1

Acceptance: 38.4%

#1738Medium

Find Kth Largest XOR Coordinate Value

ArrayBit ManipulationDivide and Conquer+5

Acceptance: 64.3%

#1740Medium

Find Distance in a Binary Tree

Binary TreeBreadth-First SearchDepth-First Search+2

Acceptance: 74.3%

#1743Medium

Restore the Array From Adjacent Pairs

ArrayDepth-First SearchHash Table

Acceptance: 74.7%

#1744Medium

Can You Eat Your Favorite Candy on Your Favorite Day?

ArrayPrefix Sum

Acceptance: 36.1%

#1746Medium

Maximum Subarray Sum After One Operation

ArrayDynamic Programming

Acceptance: 65.2%

#1747Medium

Leetflex Banned Accounts

Database

Acceptance: 62.9%

#1749Medium

Maximum Absolute Sum of Any Subarray

ArrayDynamic Programming

Acceptance: 71.1%

#1750Medium

Minimum Length of String After Deleting Similar Ends

StringTwo Pointers

Acceptance: 55.9%

#1753Medium

Maximum Score From Removing Stones

GreedyHeap (Priority Queue)Math

Acceptance: 68.6%

#1754Medium

Largest Merge Of Two Strings

GreedyStringTwo Pointers

Acceptance: 54.2%

#1756Medium

Design Most Recently Used Queue

ArrayBinary Indexed TreeDesign+3

Acceptance: 78.0%

#1759Medium

Count Number of Homogenous Substrings

MathString

Acceptance: 57.6%

#1760Medium

Minimum Limit of Balls in a Bag

ArrayBinary Search

Acceptance: 65.9%

#1762Medium

Buildings With an Ocean View

ArrayMonotonic StackStack

Acceptance: 80.9%

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