paint[i] is the color code of house i. The distance between houses i and j is |i - j|.
Find the largest distance between two houses painted in different colors. The street is guaranteed to have at least two different colors.paint=[3, 3, 5, 3, 3, 3] → 3
The only house of another color stands at position 2. The farthest house from it is the last one: 5 - 2 = 3.
paint=[4, 1, 1, 4, 2] → 4
The first and the last houses have different colors (4 and 2), and the distance between them is 4, the largest possible.
paint=[3, 3, 5, 3, 3, 3]
3
Run checks the first 3 tests in your browser. Submit checks all 91 tests on the server, hidden ones included.