leetcode849】的更多相关文章

In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. 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 closes…
public class Solution { public int MaxDistToClosest(int[] seats) { ; var len = seats.Length; ) { ; } var list = new List<int>(); ; i < len; i++) { ) { list.Add(i); } } ; ; ; ; ; i < list.Count; i++) { ]; < dis) { maxlen = dis / ; begin = li…
在一排座位( seats)中,1 代表有人坐在座位上,0 代表座位上是空的. 至少有一个空座位,且至少有一人坐在座位上. 亚历克斯希望坐在一个能够使他与离他最近的人之间的距离达到最大化的座位上. 返回他到离他最近的人的最大距离. 示例 1: 输入:[1,0,0,0,1,0,1] 输出:2 解释: 如果亚历克斯坐在第二个空位(seats[2])上,他到离他最近的人的距离为 2 . 如果亚历克斯坐在其它任何一个空位上,他到离他最近的人的距离为 1 . 因此,他到离他最近的人的最大距离是 2 . 示例…