about | help | code help+videos | done | prefs |
Write a method called Collapse1 that accepts an array of integers as a parameter and returns a new array containing the result of replacing each pair of integers with the sum of that pair. For example, if an array called nums contains the values {7, 2, 8, 9, 4, 13, 7, 1, 9, 10}, then the call to the method Collapse1 should return a new array containing {9, 17, 17, 8, 19}. The first pair from the original list 7 + 2 = 9 and so on. The given array of numbers will always be even in length. If the array is empty return the empty array. Collapse1([7, 2, 8, 9, 4, 13, 7, 1, 9, 10]) → [9, 17, 17, 8, 19] Collapse1([]) → [] Collapse1([2, 2]) → [4] ...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: 110
Copyright Nick Parlante 2017 - privacy