Question: Code a method that takes an array of integers as input and returns an array of integers as output. The value of cell i in

Code a method that takes an array of integers as input and returns an array of integers as output. The value of cell i in the returned array is the sum of cell i and all the previous even numbers if cell i is even and is the sum of cell i and all the previous odd cells if cell i is odd.

Example

input: [1,2,3,4,5,6,7,8,9]

output: [1,2,4,6,9,12,16,20,25]

Note: no side effect should occur on the input array.

USE JAVA

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!