id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Warmup 1Shifty

prev  |  next  |  chance
public static int[] shifty(int[] vals) {

    int[] results = new int[vals.length];

    for (int i = 1; i < vals.length; i++)
        results[i - 1] = vals[i];

    results[results.length - 1] = vals[0];

    return results;
}
Function Call  Return Value
shifty(new int[]{5, 4, 5})
shifty(new int[]{4, 6, 8})
shifty(new int[]{5, 7})
shifty(new int[]{1, 2, 3, 4, 5})
shifty(new int[]{7, 6, 5, 4, 3})
shifty(new int[]{1})

Experiment with this code on Gitpod.io

⬅ Back