about | help | code help+videos | done | prefs |
Assume the array has at least 2 elements. Find the longest run of numbers in ary, where the longest run can either be monotonically increasing(a[i] <= a[i+1]) or monotonically decreasing. In case of a tie for the longest run, choose the longest run that occurs first. Return the sum of the elements in the longest run. longestRun([10, 4, 3, 8, 3, 4, 5, 7, 7, 2]) → 26 longestRun([1, 2, 3, 4, 5, 6, 7, 8, 9]) → 45 longestRun([1, 2, 3, 2, 1]) → 6 ...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: 200 Post-solution available
Copyright Nick Parlante 2017 - privacy