As reported: Snap phone screen (2025).
There are meeting rooms; room i is a single row of rooms[i] seats. Place all k people in seats (one person per seat, any rooms) so that the minimum distance between two people in the same room is as large as possible, and return that distance.
The distance between two people in the same room is the number of empty seats between them. People in different rooms are not compared, and a room with one person (or nobody) adds no constraint.
Example 1
rooms = [7,8,3], k = 7
Output: 2
One placement (1 = person):
room 0: [1,0,0,1,0,0,1]
room 1: [1,0,0,1,0,0,0,1]
room 2: [1,0,0]
Every pair of neighbours in a room has at least 2 empty seats between them. With 3 empty seats required, the rooms hold only 2 + 2 + 1 = 5 people.
Example 2
rooms = [2,2], k = 3
Output: 0
One room must hold two people side by side.
Constraints: 1 ≤ rooms.length ≤ 10^5; 1 ≤ rooms[i] ≤ 10^9; rooms.length < k ≤ min(10^9, sum(rooms)) — so everyone fits and some room holds at least two people.
Code runner format: one JSON value per line: rooms, k. Implement maxMinDistance(rooms, k); the harness prints the distance.