难度:简单
 
 翻译:寻找距离最远的 1 和 -1 的组合,要求它们之间只有0
class Solution:
    def captureForts(self, forts: List[int]) -> int:
        res, t = 0, -1
        for i, fort in enumerate(forts):
            if fort == -1 or fort == 1:
                if t >= 0 and fort != forts[t]:
                    res = max(res, i - t - 1)
                t = i
        return res



















