ProdMatch
CompaniesCitiesRolesSign in

Companies

  • Google
  • Microsoft
  • Meta
  • Amazon
  • Apple
  • Atlassian
  • Nvidia
  • Oracle
  • See all 51 →

Cities

  • Bengaluru jobs
  • Hyderabad jobs
  • Pune jobs
  • Gurugram jobs
  • Noida jobs
  • Delhi NCR jobs
  • Mumbai jobs
  • Chennai jobs
  • Remote-India jobs

Roles

  • QA / SDET Engineers
  • Backend Engineers
  • Frontend Engineers
  • Full-stack Engineers
  • Data Analysts
  • Data Engineers
  • ML / AI Engineers
  • DevOps / SRE Engineers
  • All roles →

ProdMatch

  • About
  • Career guides
  • Compare
  • Salaries
  • Skills
  • DSA practice
  • Privacy
  • Terms
  • Sign in

© 2026 ProdMatch.ai · Built for India · DPDP Act 2023 compliant · Job data sourced from official company career pages.

Back to DSA
Greedymedium45 minMobile Engineer

Search Greedy Load Rebalancer

Mobile Engineer signal: greedy proof + sorting in a on-device search context. This is a ProdMatch-owned mobile engineer drill, framed as a May 2026 Unacademy Mobile Search simulation, not a copied platform question.

Company context

Unacademy · Mobile Search

Freshness

May 2026

Product surface

on-device search

ProdMatch interview simulation based on product-team patterns; not a claim of a real company question.

Question

Rebalance tokens across shards for on-device search. Each move has a cost equal to distance between shards. Compute minimum cost to make shard loads differ by at most one.

Input

  • Array of shard loads.

Output

  • Minimum movement cost.

Constraints

  • 1 <= shards <= 200000
  • Total load <= 1e12

Concepts

  • offline sync
  • local cache
  • gesture streams
  • greedy proof
  • sorting
  • load balancing

loads [0,3,0] -> move one unit left and one right, cost=2

Approach

Try framing your own approach first. The 30 seconds you think before peeking is where learning happens.

Clean Solution

Reveal the approach first.

How well did you understand?

Your rating tunes when this problem shows up again.

Common Mistakes

  • A greedy idea without a proof may fail hidden cases.
  • Do not mutate sorted keys in a way that breaks ordering.

Next Similar Problems

Sync Greedy Load RebalancermediumFeed Greedy Load RebalancermediumCache Greedy Load Rebalancerhard