Frage im Vorstellungsgespräch bei World Wide Technology

Algorithm question. Solve and write pseudo code on the white board.