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

 

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

Swap the mirror elements of a given array. Thus, the first and last elements are swapped, the second and second-to-last elements are swapped and so forth. Return the modified array.

HINT
Note that this basically reverses the array. Most people get this problem wrong not by messing up the swaps, but by not thinking through the loop.

apcsaArraysSwapMirrorElements([3, 4]) → [4, 3]
apcsaArraysSwapMirrorElements([5, 8]) → [8, 5]
apcsaArraysSwapMirrorElements([1, 2, 3, 4, 5]) → [5, 4, 3, 2, 1]

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

public int[] apcsaArraysSwapMirrorElements(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