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

 

orion.a.smith@gmail.com apcsa-lists > apcsaListSetRotation
prev  |  next  |  chance

Given an ArrayList with three Integer values, use the set() method of the ArrayList class to rotate all the values to their previous index, and return the modified ArrayList. An ideal solution will only have two statements, where the first statement uses the output of one set() method call as the input to another set() method call.


Sure, you can do a left rotation on an ArrayList by using add() and remove(), but that's too easy.

HINT

The fun version of this has a statement with three set() calls and one get() call.

apcsaListSetRotation([3, 4, 5]) → [4, 5, 3]
apcsaListSetRotation([0, 1, 0]) → [1, 0, 0]
apcsaListSetRotation([13, 13, 14]) → [13, 14, 13]

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

public ArrayList<Integer> apcsaListSetRotation(ArrayList<Integer> lst) { }

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: 220

Copyright Nick Parlante 2017 - privacy