ImagineX Interview Question

Explain your thought process behind the solution.