Heyzap Interview Question

Typical big O and easy algorithm