Algorithm problems · runnable

40 algorithm problems, solved step by step.

Classic interview problems in our own words, each solved from brute force to optimal with code you can run on the page, in 15 languages. No setup, no signup.

0/40 solved
  1. Two SumEasy
  2. Valid ParenthesesEasy
  3. Contains DuplicateEasy
  4. Valid AnagramEasy
  5. Valid PalindromeEasy
  6. Best Time to Buy and Sell StockEasy
  7. Longest Common PrefixEasy
  8. Reverse a Linked ListEasy
  9. Invert a Binary TreeEasy
  10. Climbing StairsEasy
  11. Single NumberEasy
  12. Counting BitsEasy
  13. Missing NumberEasy
  14. Roman to IntegerEasy
  15. Majority ElementEasy
  16. Maximum Depth of a Binary TreeEasy
  17. Merge Two Sorted ListsEasy
  18. Longest Substring Without Repeating CharactersMedium
  19. Maximum SubarrayMedium
  20. 3SumMedium
  21. Merge IntervalsMedium
  22. Search in Rotated Sorted ArrayMedium
  23. Coin ChangeMedium
  24. Number of IslandsMedium
  25. Kth Largest Element in an ArrayMedium
  26. Group AnagramsMedium
  27. Top K Frequent ElementsMedium
  28. Product of Array Except SelfMedium
  29. Container With Most WaterMedium
  30. Daily TemperaturesMedium
  31. Jump GameMedium
  32. Rotate a MatrixMedium
  33. House RobberMedium
  34. Word BreakMedium
  35. Course ScheduleMedium
  36. Binary Tree Level Order TraversalMedium
  37. Trapping Rain WaterHard
  38. N-QueensHard
  39. Edit DistanceHard
  40. Largest Rectangle in HistogramHard
Questions & answers

Coding problems, explained

Are these the official problem statements?

No. Every statement, example and test value here is written by us. The problem names are the common ones people search for, and the solutions explain the standard approaches from brute force to optimal.

Can I run the solutions?

Yes. Every approach is a complete program with a Run button that executes it on the CompileBytes engine. Edit the code and run it again to try your own inputs.

Is there a judge or a submit button?

No. These are worked solutions to read and run, not a graded test. To practise, open the compiler from any problem and write your own version before reading the answers.

Is this free? Do I need an account?

Every problem is free to read, run, edit and copy. No account is required.