Altimetrik Interview Question

A basic coding problem on java