id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

andersoniii.edwin@cusd80.com > Collapse1
prev  |  next  |  chance

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)

public int[] Collapse1(int[] nums) }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 110

Copyright Nick Parlante 2017 - privacy