Google interview question

2 algorisms and 1 debugging question