IBM Interview Question

Didn’t pass the coding round