Google interview question

Solve this leet code under 30min