← 返回 roblox 的题目列表Maximize Distance to Closest Person (LeetCode 849)
类型:qbank
Given a row of occupied and empty seats, choose an empty seat that maximizes distance to the closest occupied person.
Examples
Example 1:
Input: seats = [1,0,0,0,1,0,1]
Output: 2
Explanation:
Sitting at index 2 puts Alex 2 seats away from the closest taken seat.
Example 2:
Input: seats = [1,0,0,0]
Output: 3
Explanation:
Sitting at the last seat puts Alex 3 seats away from the only occupied seat.
Example 3:
Input: seats = [0,1]
Output: 1
Constraints
2 <= seats.length <= 2 * 10^4
seats[i] is 0 or 1.
At least one seat is empty.
At least one seat is occupied.