about | help | code help+videos | done | prefs |
Heads up, this is a harder problem. It's actually a part of the merge sort algorithm, which shows up on the APCSA exam. Given two arrays of ints which are both in order from least to greatest, return a new array of ints which has all the elements from the two original arrays, in order. Any values in both input arrays should be in the output as many times as they occur in the input. Precondition: both inputs will have at least one element. HINT: the output array will be sized to the length of the sum of the lengths of the input arrays. You may actually want a while loop to do this, and two counters (one for each of the inputs).apcsaArraysMergeInputs([0, 3], [1, 4]) → [0, 1, 3, 4] apcsaArraysMergeInputs([0, 2, 3, 4], [1, 2, 5, 6]) → [0, 1, 2, 2, 3, 4, 5, 6] apcsaArraysMergeInputs([1], [1]) → [1, 1] ...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: 260
Copyright Nick Parlante 2017 - privacy