Checkpoint: follow the path
Challenge on lesson: Checkpoint: follow the path
CHALLENGE
Difficulty: intermediate+25 XP
Implement int firstRepeat(int[][] grid, int row, int col): each cell holds 10*row + col. Starting at (row, col), jump to the cell it names; return the code of the first cell visited twice, or -1 if a jump leaves the grid. Cap steps at 2 × cell count. This is a traced walk: maintain the visited knowledge, one jump per iteration.
Press Submit to check your solution.
Back to lesson: Checkpoint: follow the path