TODO: We will give you an array of non-zero integers. You will output an *array
ID: 3736405 • Letter: T
Question
TODO: We will give you an array of non-zero integers. You will output an *array that would generate the input array if it was a parameter to count. For example, if the input has input[6] is 4, your output should have 4 sixes in it. * The output you produce should be in ascending order. If given an array of length 0, you should output an array of length ExampLes: *expandCnew int 13, 2, 53) -10, 0, 0, 1, 1, 2, 2, 2, 2, 2 * expandCnew int 0, 0, 3t)-12, 2, 23 * expandC) HINTS: *If the input array is 17, 2, 53, the length of the output array will be 7+2+5 *You can put loops inside loops. public static int] expand(int input) f return new int[0];Explanation / Answer
public class ExpandArray { public static int[] expand(int[] input) { int size = getSum(input); int[] arr = new int[size]; int k = 0; for (int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.