NewThe Learning module is now liveSee what's new

For an array nums of length n and a non-negative integer t with 0 ≤ t < n, a cyclic t-shift of nums is the array obtained by taking the last t elements of nums and moving them, in order, to the front. Concretely:

  • t = 0 leaves the array unchanged: [nums[0], nums[1], ..., nums[n-1]].
  • t = 1 produces [nums[n-1], nums[0], nums[1], ..., nums[n-2]].
  • t = 2 produces [nums[n-2], nums[n-1], nums[0], nums[1], ..., nums[n-3]].
  • t = n-1 produces [nums[1], nums[2], ..., nums[n-1], nums[0]].
Test Cases
Input
Output
Expected