World Wide Technology Interview Question

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