package leetcode;

/**
 * https://leetcode.com/problems/maximize-distance-to-closest-person/
 */
public class Problem849 {
    public int maxDistToClosest(int[] seats) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem849 prob = new Problem849();
    }
}

@@ -175,128 +175,483 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem849 prob = new Problem849()
+int max = 0;%0A        int prevIdx = -1;%0A        for (int i = 0; i %3C seats.length; i++) %7B%0A            if (seats%5Bi%5D == 1) %7B%0A                if (prevIdx == -1) %7B%0A                   max = Math.max(max, i);%0A                %7D else %7B%0A                    max = Math.max(max, (i - prevIdx) / 2);%0A                %7D%0A                prevIdx = i;%0A            %7D%0A        %7D%0A        if (prevIdx != -1) %7B%0A            max = Math.max(max, seats.length - prevIdx - 1);%0A        %7D%0A        return max
 ;%0A  

Solve problem 849