about | help | code help+videos | done | prefs |
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. If the array is empty, return 0 for the range. range([1, 2, 3, 4, 5, 6]) → 6 range([10, 4, 17, 20, 11, 15, 19]) → 17 range([3, 3, 3, 3, 3]) → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 100 Post-solution available
Copyright Nick Parlante 2017 - privacy