Fewest Relay Hops to Push a Windows Update Down a Peer Chain
Last updated: November 29, 2026
Quick Overview
Machines in a line share an update through Delivery Optimization style peering, and machine i can forward the payload to any machine up to reach[i] positions ahead. Return the fewest forwarding hops needed for the payload to get from machine 0 to the last machine, or -1 if it cannot.
Microsoft
November 29, 20260
0
0 solved
Machines in a line share an update through Delivery Optimization style peering, and machine i can forward the payload to any machine up to reach[i] positions ahead. Return the fewest forwarding hops needed for the payload to get from machine 0 to the last machine, or -1 if it cannot.
A common Microsoft phone or technical screen problem, framed around peer to peer update distribution in Windows. The interviewer wants to see whether you recognize the BFS-by-layers structure and collapse it into a linear greedy scan instead of reaching for DP.
What the Interviewer Expects
- Recognize that each hop explores a contiguous range of machines, like a BFS level
- Produce an O(n) greedy with O(1) extra space
- Explain why extending to the farthest reachable index is always safe
- Handle the unreachable case and the single machine case
- Trace the algorithm on a small example out loud
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you also return the actual relay machines chosen?
- What changes if each hop has a cost and you want minimum total cost instead of hop count?
- How would you handle reach values that change while the update is in flight?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: array
reachof non-negative integers, length n. - Output: minimum number of hops from index 0 to index n - 1, or -1 if impossible.
- A machine with
reach[i] = 0is a dead end unless somet...
High-Level Design
Think of the hops as BFS levels. After h hops, the set of machines the payload can be on is a contiguous prefix [0, current_end], because if you can reach j you can also stop short at anything befor...