1
class Solution {
2
public int maxDistance(int[] colors) {
3
int l = 0, r = colors.length - 1;
4
while (colors[colors.length - 1] == colors[l]) l++;
5
while (colors[0] == colors[r]) r--;
6
return Math.max(r, colors.length - 1 - l);
7
}
8
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0