Back to problems

Maximize Distance to Closest Person

Algorithm · Roblox · Medium

You receive an array named seats: a value of 1 at seats[i] indicates that position i is taken, while 0 indicates an available position. The array always contains at least one open seat and one occupied seat. Alex must choose a seat that makes his distance to the nearest occupied position as large as possible. Return that greatest achievable distance. Examples Example 1: Input: seats = [1,0,0,0,0,1] Output: 2 Explanation: Choosing index 2 leaves Alex 2 seats from the closest…

Checking your access…