Yahoo interview question

7 LeetCode easy/medium, brain teaser