Springworks Interview Question

I failed the coding round