Two Furthest Houses With Different Colors
Easy
Arrays
Array
Greedy
Given colors[], find max distance |i-j| where colors[i] ≠ colors[j].
Constraints
2 ≤ len ≤ 100
Examples
Example 1:
Input: 1 1 1 6 1 1 1
Output: 3
Example 2:
Input: 1 8 3 8 3
Output: 4
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console