Talentd
FleetCode
Make and follow sheets.Sign in

Solutions, explained

Every approach from brute force to the best one, with code in Python, Java, C++ and more.

Has video
Array1,169Hash Table465String428Math320Greedy317Dynamic Programming305Sorting294Depth-First Search205Binary Search182Breadth-First Search164Matrix157Tree157All topics

Medium · 294 results

3Sum

15.3Sum

MediumArraySortingTwo Pointers40.1% acceptance57 companiesVideo
4Sum

18.4Sum

MediumArraySortingTwo Pointers42.0% acceptance20 companiesVideo
Sort List

148.Sort List

MediumDivide and ConquerLinked ListMerge Sort65.2% acceptance9 companiesVideo
H-Index

274.H-Index

MediumArrayCounting SortSorting41.8% acceptance8 companiesVideo
Wiggle Sort

280.Wiggle Sort

MediumArrayGreedySorting68.5% acceptance4 companiesPremium elsewhere, free hereVideo
Heaters

475.Heaters

MediumArrayBinary SearchSorting42.9% acceptance12 companiesVideo
Showing 1–50 of 294

How to use these solutions

Each solution breaks the problem into approaches, usually from brute force to the best one, and explains why each works. Code comes in Python, Java, C++ and other languages. Knowing why an approach works matters more in an interview than remembering the code.

  • Try the problem first. Give it at least 20 minutes before you open the solution.
  • Read every approach. The brute force shows you the problem; the faster ones show the pattern.
  • Check the complexity. Note the time and space of each approach and what makes the difference.
  • Write it yourself. Close the solution and code it from memory in the editor.
  • Come back in a week. Solving it again later is what makes the pattern stick.