Google Interview Question

An easy-mid level leetcode question