FastPrepPlace K Buildings to Minimize Maximum Grid Distance
Problems/Place K Buildings to Minimize Maximum Grid Distance

Place K Buildings to Minimize Maximum Grid Distance

Oracle logoOracle● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Oracle onsite interview. The report gives the goal of placing K buildings to make the largest distance as small as possible on a grid. It also gives the 8-by-8 limit. It does not say which distance to use. Our version is about 97% the same as the reported question.

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) → int

Examples

Example 1

rows = 3columns = 3k = 1return = 2

Placing the building in the center leaves every corner at Manhattan distance 2.

Example 2

rows = 2columns = 3k = 2return = 1

Buildings in the middle column make every cell at most one step from a building.

Constraints

  • 1 <= rows, columns <= 8
  • 1 <= 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

Oracle interview experiences

  • Oracle SWE Onsite Interview Experience: 1 Experience
All Oracle interview questionsSee Oracle hiring insights
Saved
class Solution {
    public int minimumMaximumDistance(int rows, int columns, int k) {
        // Write your code here.
    }
}
Checking account…