Google interview question

Leetcode-type questions. Two per interview.