Google interview question

A leetcode easy level problem.