IBM interview question

Coding questions were asked like 2