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 challengesMax Sum Shift

Gamified challenge · Fixed sliding window

Max Sum Shift

tips[i] is what shift i earns in tips (a negative number is a fine for a broken plate). You may work exactly k consecutive shifts, with 1 ≤ k ≤ len(tips).

Write bestShift(tips, k) that returns the largest total any run of k consecutive shifts can earn. For tips = [4, 2, 7, 1, 8, 3] and k = 2 the runs earn 6, 9, 8, 9 and 11, so the answer is 11.

Re-adding every window works, but try to move from one window to the next with one addition and one subtraction.

Sign in to play Max Sum Shift

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