2078. Two Furthest Houses With Different Colors
var maxDistance = function(colors) {
let result = -1;
for (let i = 0; i < colors.length; i++) {
for (let j = colors.length-1; j > i ; j--) {
if (colors[j] !== colors[i]) {
result = Math.max(result, j - i);
}
}
}
return result;
};