Minimum Upload Bandwidth to Sync a Photo Queue Before Morning

Last updated: November 29, 2026

Quick Overview

An iPhone must upload photos to iCloud in queue order while charging overnight. Each hour it can upload at most B megabytes, and a photo cannot be split across hours. Given photo sizes and H hours, return the smallest integer B that finishes the queue in time.

Apple
Coding & Algorithms
Software Engineer
Apple
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


An iPhone must upload photos to iCloud in queue order while charging overnight. Each hour it can upload at most B megabytes, and a photo cannot be split across hours. Given photo sizes and H hours, return the smallest integer B that finishes the queue in time.

Background sync scheduling is a real concern for iCloud Photos, and this question tests binary search on the answer. The interviewer checks that you identify the monotonic feasibility predicate and the right search bounds.

What the Interviewer Expects
  • Recognize that feasibility is monotonic in B
  • Set bounds lo = max photo size and hi = total size
  • Write a greedy feasibility check that packs hours in order
  • Binary search for the smallest feasible B
  • Explain O(n log S) complexity
Key Topics to Cover
binary search on answer
greedy
feasibility checks
monotonicity
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
  • Photos may be uploaded in any order; does the answer change and how hard is it?
  • Bandwidth varies by hour; each hour has its own cap times a multiplier B.
  • Return the hour in which each photo will be uploaded.
  • What if H is smaller than one hour per largest photo?
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 ints sizes (MB) and int H >= 1. Output: minimal integer B such that the queue can be uploaded in at most H hours with whole photos per hour. If the queue is empty, return 0...

High-Level Design

For a fixed B, the greedy check fills each hour with as many consecutive photos as fit and counts hours used; greedy is optimal because delaying a photo to a later hour never helps. If B works, any la...


Submit Your Answer
Markdown supported