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

 

jebbert@volusia.k12.fl.us > swapAdjacent
prev  |  next  |  chance

Write a method that accepts an array of integers of any length. Return the array with adjacent pairs of integers "swapped". If there are an odd number of integers, the last number will not have a partner to swap with and will just remain in its regular place.


swapAdjacent([5, 8, 13, 4, 7]) → [8, 5, 4, 13, 7]
swapAdjacent([6]) → [6]
swapAdjacent([]) → []

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

public int[] swapAdjacent(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: 340

Copyright Nick Parlante 2017 - privacy