Google interview question

An easy-mid level leetcode question