← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given an array seats where seats[i] = 1 means seat i is occupied, and seats[i] = 0 means it is empty. There is at least one empty seat and at least one occupied seat.
Alex wants to sit so that the distance between him and the closest occupied seat is maximized. Return the maximum distance to the closest person.
1 <= seats.length <= 2^12seats[i] is either 0 or 1.0 and at least one 1 in seats.Input:
seats = [1,0,0,0,1,0,1]
Output:
4
Explanation: The maximum distance to the closest person is 4 seats away (the seat marked with the red circle).

Input:
seats = [1,0,0,0]
Output:
3
Explanation: There are two possible scenarios to sit (seats 2 or 3) with a maximum distance of 3 seats away from the closest person.
Input:
seats = [0,1,0,0,1,1,1,0]
Output:
4