IBM Interview Question

They asked me to explain the approach I used in my code during the coding round.