Pocket Gems Interview Question

Algorithm, big O