EMIS Group interview question

Coding part