XYZ Interview Question

regarding the coding and performance