Generation

generate functionTue, 24 Jan 2023

how to shift an array to the right

int[] rightShift(int[] arr, int shiftBy) { int[] result = new int[arr.length]; for (int i = 0; i < arr.length; i++) { result[(i + shiftBy) % arr.length] = arr[i]; } return result; }

Want to kickstart your project?Use the new AI Studio to create your code