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 challengesTruck Pair Loader

Gamified challenge · Two pointers

Truck Pair Loader

weights lists the crates in the yard in non-decreasing order, and the truck carries exactly two crates whose weights must add up to exactly capacity.

Write pairSum(weights, capacity) (pair_sum in Python) that returns the 0-based indices [i, j] of two different crates with i < j and weights[i] + weights[j] == capacity. If several pairs work, any one is accepted. If none does, return [-1, -1].

For weights = [2, 7, 11, 15] and capacity = 9 the answer is [0, 1], because 2 + 7 = 9.

Sign in to play Truck Pair Loader

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