Pick the Data Center Region With the Fewest Peers in Budget

Last updated: November 29, 2026

Quick Overview

Given n regions connected by weighted latency links and a latency budget, find the region that can reach the fewest other regions within the budget. Break ties by returning the region with the largest index.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given n regions connected by weighted latency links and a latency budget, find the region that can reach the fewest other regions within the budget. Break ties by returning the region with the largest index.

Shows up in Meta onsite loops as an all-pairs shortest path question with a small n, framed around choosing a region for an isolated canary or a disaster-recovery drill. Interviewers check that you pick Floyd-Warshall or repeated Dijkstra deliberately based on graph size and density.

What the Interviewer Expects
  • Recognize the need for all-pairs distances
  • Choose Floyd-Warshall for small dense graphs and justify it
  • Correctly initialize the distance matrix including duplicate links
  • Implement the tie-break exactly as specified
  • Compare with running Dijkstra from every node
Key Topics to Cover
Floyd-Warshall
All-pairs shortest path
Dijkstra
Tie-breaking
Adjacency matrix
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
  • When would n runs of Dijkstra beat Floyd-Warshall?
  • How would you handle the budget changing frequently across many queries?
  • Could you stop each Dijkstra early once distances exceed the budget?
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
  • n up to 100 regions, undirected links (u, v, latency) with positive latency.
  • For each region, count other regions with shortest-path latency <= budget.
  • Return the region with the smallest ...
High-Level Design

With n <= 100, Floyd-Warshall at O(n^3) = 10^6 steps is simple and fast. Its invariant: after processing intermediate node k, dist[i][j] is the shortest path using only nodes 0..k as interme...


Submit Your Answer
Markdown supported