Google interview question

Some simple algorithm question,