about | help | code help+videos | done | prefs |
Write a method that returns the "increasing sum" of the integers in an array. The "increasing sum" is the sum of all of the integers that are higher than the one immediately before that number in the array. The first number in the array is always part of the sum since it has no number before it. For example, in the array {7,3,2,1} only the 7 is counted as part of the sum, so the sum is 7. However in the array {2,5,10,20}, all numbers are counted for a total of 37. In the array {5,3,4,2,3} the sum is found by adding 5+4+3 since these are all the numbers that are greater than the number directly before it. You may assume the array will contain at least one number. The array can contain any integers in any order, including negatives and zero. As a pre-condition, you may assume that the array will contain at least one number. may16_2016_APSLHL_incSum([5, 4, 3, 2, 1]) → 5 may16_2016_APSLHL_incSum([17, 15, 12, 20, 16, 14, 11, 5]) → 37 may16_2016_APSLHL_incSum([73]) → 73 ...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