ABC interview question

Coding part