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 challengesShortest Shopping Trip

Gamified challenge · Variable sliding window

Shortest Shopping Trip

stalls[i] is the one item stall i sells (a letter), and need is your shopping list, also letters. A letter that appears twice in need means you need two stalls selling it.

Write minWindow(stalls, need) that returns the shortest run of consecutive stalls (a substring of stalls) that covers everything on the list. For stalls = "ADOBECODEBANC" and need = "ABC" the answer is "BANC". If no run covers the list, return "".

If several runs tie for shortest, any of them is accepted. Grow a window on the right until nothing is missing, then shrink it from the left while it still covers the list.

Sign in to play Shortest Shopping Trip

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