Google interview question

Some algorithm questions.