Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try thinking in reverse. Given the grid, how can you tell if a colour was painted last?
Solve with full IDE support and test cases