id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

range


Write a method named range that takes an array of integers as a parameter and returns the range of values contained in the array. The range of an array is defined to be one more than the difference between its largest and smallest element. For example, if the largest element in the array is 15 and the smallest is 4, the range is 12. If the largest and smallest values are the same, the range is 1.


range([1, 2, 3, 10]) → 10
range([-1000000, 1000000, 4, 3, 19, 17]) → 2000001
range([-2000, -1998, -1990]) → 11

...Save, Compile, Run (ctrl-enter)

public int range(int [] a){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 100

Copyright Nick Parlante 2017 - privacy