Place K Buildings to Minimize Maximum Grid Distance
Updated
Problem statement
Consider an empty grid with rows rows and columns columns. Place exactly k buildings in distinct cells.
The distance from a cell to its closest building is the minimum Manhattan distance to any building. Return the smallest possible value of the maximum such distance over every grid cell.
Function
minimumMaximumDistance(rows: int, columns: int, k: int) → intExamples
Example 1
rows = 3columns = 3k = 1return = 2Placing the building in the center leaves every corner at Manhattan distance 2.
Example 2
rows = 2columns = 3k = 2return = 1Buildings in the middle column make every cell at most one step from a building.
Constraints
1 <= rows, columns <= 81 <= k <= rows * columns- Buildings occupy distinct cells.
More Oracle Onsite Interview questions
- Course ScheduleONSITE INTERVIEW · Seen Nov 2026
- Shortest Subarray with Sum at Least KONSITE INTERVIEW · Seen Nov 2026
- Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
- Minimum Meeting RoomsONSITE INTERVIEW · Seen Nov 2026
- Shortest Window with Required CountsONSITE INTERVIEW · Seen Nov 2026
- Maximum Subarray Sum with One DeletionONSITE INTERVIEW · Seen Nov 2026
- Shortest Deletion for Distinct CharactersONSITE INTERVIEW · Seen Nov 2026
- Count Dropped Rate-Limited RequestsONSITE INTERVIEW · Seen Nov 2026
- Design Authentication ManagerONSITE INTERVIEW · Seen Oct 2026
- Maximum Bouquet ValueONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Word Search IIAmazon · ONSITE INTERVIEW
- Sudoku Puzzle SolverConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
- Cats, Rabbits, and Snails Board GameAsana · ONSITE INTERVIEW
- Enumerate Top-to-Bottom Grid PathsGoogle · ONSITE INTERVIEWGoogle interview questions
- Boggle Word FinderBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Solve a Sudoku BoardZipRecruiter · ONSITE INTERVIEWZipRecruiter interview questions
- Check Each Word in a Character GridZillow · ONSITE INTERVIEWZillow interview questions
- Search a Row- and Column-Sorted MatrixByteDance · ONSITE INTERVIEWByteDance interview questions
- Search a 2D MatrixWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
- K-th Smallest Value in a Sorted MatrixPhonePe · ONSITE INTERVIEWPhonePe interview questions