Kotlinlearncs.online LogoJava
Return to List

Solve: Array Double Upper

Created By: Chris Taylor
/ Version: 2023.7.0

Write the recursive method, arrayDoubleUpper, that accepts two arguments and, when called by the provided arrayDoubleUpper(int[] nums) method, returns the same array of ints where each int in the returned array is double the value of the original element. You may assume that the array passed is not null.

int[] arrayDoubleUpper(int[] nums, int index) {
return null; // You may need to remove this starter code
}
/**
* Returns the array with all the elements containing twice the value of the original elements.
*
* @param nums The integers to be doubled
* @return The integers that have been doubled
*/
int[] arrayDoubleUpper(int[] nums) {
return arrayDoubleUpper(nums, 0);
}

Related Lessons

Stuck? You may find these lessons helpful: