about | help | code help+videos | done | prefs |
apcsaArraysRotateRight
Given an array of int values, perform a right rotation on the elements such that the element values "move up" one in terms of their indexes, including the wraparound effect where the last element of the input becomes the first element of the output. Return an array with the right rotation performed relative to the input. Precondition: arr will have at least one element. HINT: this problem is actually easier to solve by creating a separate output array that you then return, rather than by mutating values from the input array. Both techniques are definitely possible, but a separate output is a bit easier to think through.apcsaArraysRotateRight([5, 6, 2, 0, 4]) → [4, 5, 6, 2, 0] apcsaArraysRotateRight([1, 2, 3]) → [3, 1, 2] apcsaArraysRotateRight([0, 1, 2, 3, 4]) → [4, 0, 1, 2, 3] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 240
Copyright Nick Parlante 2017 - privacy