Altimetrik interview question

A basic coding problem on java