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

 

rmueller@lasacs.com > swapOutermostThree
prev  |  next  |  chance

Given an array of integers return an array with the 1st and last element swapped (i.e. the outermost elements swapped), the 2nd outermost elements swapped, and the 3rd outermost elements swapped, EXCEPT don't swap the middle two elements (for an array with an even number of elements) or middle three elements (for an array with an odd number of elements).


swapOutermostThree([1, 2, 3, 4]) → [4, 2, 3, 1]
swapOutermostThree([1, 2, 3, 4, 5]) → [5, 2, 3, 4, 1]
swapOutermostThree([1, 2, 3, 4, 5, 6]) → [6, 5, 3, 4, 2, 1]

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

public int[] swapOutermostThree(int[] arr) { }

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

Post-solution available

Copyright Nick Parlante 2017 - privacy