最后更新于3年前
class Solution: def maxDistance(self, colors: List[int]) -> int: n = len(colors) res = 0 for i in range(n): for j in range(i): if colors[i] != colors[j]: res = max(res, i-j) return res