Split a Group Order Into K Equal Shares Using Every Item

Last updated: November 29, 2026

Quick Overview

A group Uber Eats order has item prices in cents. Decide whether the items can be divided among k people so that every person's items sum to exactly the same amount, with every item assigned to someone.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


A group Uber Eats order has item prices in cents. Decide whether the items can be divided among k people so that every person's items sum to exactly the same amount, with every item assigned to someone.

An Uber onsite backtracking question that rewards strong pruning. Interviewers expect the target computation, a sort for early failure, and symmetry breaking so equal empty buckets are not tried twice.

What the Interviewer Expects
  • Checks that the total is divisible by k and no item exceeds the target
  • Sorts prices descending so large items fail fast
  • Assigns each item to a bucket with backtracking
  • Skips buckets with the same current sum to break symmetry
  • Mentions the bitmask DP alternative and its O(n * 2^n) cost
Key Topics to Cover
backtracking
partition problem
pruning
bitmask DP
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Return the actual split, not just yes or no.
  • What if shares only need to be within 50 cents of each other?
  • How large can n be before the bitmask DP is necessary?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list of positive integer prices, integer k >= 1.
  • Output: True if a partition into k groups of equal sum exists.
  • n is small (up to about 16)....
High-Level Design

Let target = total / k; if it is not an integer, or the largest item exceeds it, return False. Sort descending and place items one at a time into k buckets. For each item, try every bucket whose sum...


Submit Your Answer
Markdown supported