Autobrains interview question

Regarding my solution to programming exercise