← Unit 4 · all exercises
Saved in this browser only

Add up a grid

Return the total of every number in a two-dimensional array.

int sum(int[][] grid)

Solution.java
Loading editor…
Results

Examples

  • Solution.sum(new int[][]{{1, 2}, {3, 4}}) → 10
  • Solution.sum(new int[][]{{5}}) → 5

There are also 3 hidden tests you can't see. Solve the problem, not the examples.