ImagineX interview question

Explain your thought process behind the solution.