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 challengesUnique Bead Necklace

Gamified challenge · Variable sliding window

Unique Bead Necklace

beads is a string where each letter is the colour of one bead (r red, g green, and so on). You may cut out one contiguous stretch, but no colour may appear in it more than once.

Write longestUnique(beads) that returns the length of the longest such stretch. For "rgbrgbb" the answer is 3 (for example rgb); for "rrrr" it's 1, and an empty string gives 0.

Checking every stretch works for short strings; a window that grows on the right and shrinks on the left does it in one pass.

Sign in to play Unique Bead Necklace

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