GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesBucket of Scores

Gamified challenge · Bucket sort

Bucket of Scores

scores holds whole-number scores (0 or more, in no order, repeats allowed). Imagine them sorted: the gap between two neighbours is the bigger minus the smaller. Return the largest gap.

With fewer than two scores there is no gap, so return 0. Write maxGap(scores); for [3, 6, 9, 1] the sorted order is 1, 3, 6, 9 and the answer is 3.

Sorting works, but try for O(n): put the scores into n − 1 equal-width buckets between the minimum and maximum. The largest gap is at least the bucket width, so it always runs from one non-empty bucket's maximum to the next non-empty bucket's minimum.

Sign in to play Bucket of Scores

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account