Deloitte interview question

A easy to moderate level DSA problem