0849. Maximize Distance to Closest Person
Last updated
Last updated
https://leetcode.com/problems/maximize-distance-to-closest-person
You are given an array representing a row of seats
where seats[i] = 1
represents a person sitting in the ith
seat, and seats[i] = 0
represents that the ith
seat is empty (0-indexed).
There is at least one empty seat, and at least one person sitting.
Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized.
Return that maximum distance to the closest person.
Example 1:
Example 2:
Example 3:
Constraints:
2 <= seats.length <= 2 * 104
seats[i]
is 0
or 1
.
At least one seat is empty.
At least one seat is occupied.