Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
The constraints are small. Can you try the combination of every two houses?
Greedily, the maximum distance will come from either the pair of the leftmost house and possibly some house on the right with a different color, or the pair of the rightmost house and possibly some house on the left with a different color.