Block interview question

first round is all algorithm