Google interview question

- leet code hard question