← Unit 4 · all exercises
Saved in this browser only

The spread

Return the difference between the largest and smallest numbers. The array always has at least one item, so a single item has a spread of zero.

int spread(int[] values)

Solution.java
Loading editor…
Results

Examples

  • Solution.spread(new int[]{1, 9, 5}) → 8
  • Solution.spread(new int[]{4}) → 0

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