about | help | code help+videos | done | prefs |
apcsaArraysSwapPairElementsWhenDisordered
This function swaps the even-index values of the array with their odd-index pairs, but only when the earlier value is greater than the later value. Thus, the element at index 0 is (potentially) swapped with the element at index 1, the element with index 2 is (potentially) swapped with the element at index 3, and so on. Note that this function returns a whole array, not just an int. Precondition: the input array's length will be an even number. apcsaArraysSwapPairElementsWhenDisordered([3, 4]) → [3, 4] apcsaArraysSwapPairElementsWhenDisordered([8, 5, 3, 4, 5, 1]) → [5, 8, 3, 4, 1, 5] apcsaArraysSwapPairElementsWhenDisordered([9, 2, 4, 6]) → [2, 9, 4, 6] ...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: 250
Copyright Nick Parlante 2017 - privacy