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 challengesToken Merger

Gamified challenge · Hash maps

Token Merger

Split every word in words into single letters (each list entry counts separately, so repeats count more). Then make up to k merges: count every adjacent pair of symbols in every word (overlaps count: aaa has the pair a,a twice), pick the most frequent pair, and replace each occurrence in every word, scanning left to right without overlaps, by one symbol glued together.

Ties go to the smallest pair: compare the left symbols as strings, then the right symbols ("a" < "ab" < "b"). Stop early if no word has two symbols left. Write bpeMerges(words, k) returning the merges in order, each written left+right.

Example: ["banana", "bandana", "ban", "nab"], k = 4 gives ["a+n", "b+an", "an+a", "a+b"]: a,n appears 5 times, then b,an 3 times, then an,a twice; in the last round every pair appears once, and a,b has the smallest left symbol.

Sign in to play Token Merger

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