Optimal Office Placement
Updated
Problem statement
For this exercise, assume a width by height rectangular grid has no obstacles and every cell may contain an office. Place exactly offices offices in distinct cells.
The distance from cell (x,y) to office (a,b) is |x-a| + |y-b|. A cell is served by its nearest office. For a placement, find each cell’s distance to its nearest office. The largest of these distances is the placement’s radius. Include the office cells themselves in this calculation.
Place the offices so this radius is as small as possible, and return that radius. Office identities and the order in which they are placed do not matter.
Function
minOfficeRadius(width: int, height: int, offices: int) → intExamples
Example 1
width = 3height = 3offices = 1return = 2Put the office in the center. Every corner is at Manhattan distance 2.
Example 2
width = 4height = 1offices = 2return = 1Offices at positions 0 and 2 serve every cell within distance 1.
Example 3
width = 2height = 2offices = 4return = 0Every cell contains an office, so every nearest distance is zero.
Constraints
1 <= width, height <= 4, so there are at most16cells.1 <= offices <= width * height.- Exactly one office may occupy a chosen cell; all grid cells are eligible.
More Roblox Online Assessment questions
- Centered Block Placement QueriesOA · Seen Oct 2026
- Robot Navigation Around LasersOA · Seen Oct 2026
- Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
- Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
- Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
- Track Received Byte RangesOA · Seen Sep 2026
- Break a PalindromeOA · Seen Jun 2026
- Count Pairs Differing in One DigitOA · Seen Oct 2025
- Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
- Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025
Similar questions at other companies
- Count Valid A-B-C Sequences Under a Modulo-Four RuleInfosys · OAInfosys interview questions
- Empty ShelfSquarepoint Capital · OASquarepoint Capital interview questions
- Cave AdvantureMeta · OAMeta interview questions
- The Three Knights 🎠TikTok · OATikTok interview questions
- Complete a Sudoku BoardJP Morgan Chase · OAJP Morgan Chase interview questions
- Word SearchBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Four-by-Four Boundary GridSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Alternating Parity PermutationsGoldman Sachs · OAGoldman Sachs interview questions
- Minimum Changes to Draw a YZipRecruiter · OAZipRecruiter interview questions
- Count L-Shaped PlotsUber · OAUber interview questions
Interview reports that mention this question
Roblox interview experiences
- Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
- Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
- Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
- Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
- Roblox New Grad Coding Rounds: 23 Experiences (Part 2 of 7)