id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-arrays > apcsaArraysSwapPairElements
prev  |  next  |  chance

Swap the even-index values of the input array with their odd-index pairs. Thus, the element at index 0 is swapped with the element at index 1, the element with index 2 is swapped with the element at index 3, and so on. Return the modified array. Precondition: the number of elements in nums is even.


apcsaArraysSwapPairElements([3, 4]) → [4, 3]
apcsaArraysSwapPairElements([5, 8]) → [8, 5]
apcsaArraysSwapPairElements([9, 2, 4, 6]) → [2, 9, 6, 4]

...Save, Compile, Run (ctrl-enter)

public int[] apcsaArraysSwapPairElements(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 250

Copyright Nick Parlante 2017 - privacy