Google interview question

I was asked to solve questions roughly leetcode-medium in difficultly.