Google interview question

LeetCode with follow ups , behavioral