Google Interview Question

Basic algorithmic coding question, leetcode style