comefrom: <doocs>2078.Two Furthest Houses With Different Colors_1.py
code: def maxDistance( colors: List[int]) -> int:
      n = len(colors)
      if colors[0] != colors[-1]:
          return n - 1
      i, j = 1, n - 2
      while colors[i] == colors[0]:
          i += 1
      while colors[j] == colors[0]:
          j -= 1
      return max(n - i - 1, j)
masked: def sample_funcname ( var_0 : List [ int ] ) -> int :
      var_4 = len ( var_0 )
      if var_0 [ 0 ] != var_0 [ - 1 ] :
          return var_4 - 1
      var_7 , var_9 = 1 , var_4 - 2
      while var_0 [ var_7 ] == var_0 [ 0 ] :
          var_7 += 1
      while var_0 [ var_9 ] == var_0 [ 0 ] :
          var_9 -= 1
      return max ( var_4 - var_7 - 1 , var_9 )
  