Google interview question

data structure algorithm medium difficulty question