Practice · 1 of 5
Sum the neighbors
CHALLENGE
Difficulty: intermediate+25 XP
Return the **sum of all in-bounds neighbors** of cell (r, c) — the 8 surrounding cells, excluding the cell itself. Implement process(int[][] g, int r, int c).
Example: in {{1,2},{3,4}}, cell (0,0) has neighbors 2, 3, 4 → 9.
Press Submit to check your solution.
Back to lesson: Practice: Grid lab: axes, neighborhoods, walls