Amdocs interview question

spiral