Learning Heroes interview question

I was asked to solve an image optimisation problem