about | help | code help+videos | done | prefs |
Write a method that returns the sum of all the integers in array 'nums' in all of the array indicies from 'low' to 'high' inclusive. As preconditions, you may assume that 'low' and 'high' are non-negative, but you may NOT assume that 'low'<='high'. If 'high'<'low' then the result is zero. If 'low' is greater than the last index in the array, also return zero. If 'high' is greater than the last index of the array, find the sum from 'low' all the way to the end of the array. Look at the test data for examples. You MAY solve this recursively, but recursion is NOT required. feb_22_2019_APSLHL_sumBetween([5, 3, 7, 19, 1, 4, 22, 8, 13], 3, 4) → 20 feb_22_2019_APSLHL_sumBetween([5, 7, 1, 200, 50, 7, 3, 4, 9], 3, 5) → 257 feb_22_2019_APSLHL_sumBetween([8, 9, 2, 30], 1, 8) → 41 ...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: 290
Copyright Nick Parlante 2017 - privacy