Cut time to optimize an image with many colors in half.

O(n^2) -> O(n).