Skip to content

Instantly share code, notes, and snippets.

@maxiwer
Created September 26, 2024 15:59
Show Gist options
  • Save maxiwer/a9b24cfde70858fed18db43bff549325 to your computer and use it in GitHub Desktop.
Save maxiwer/a9b24cfde70858fed18db43bff549325 to your computer and use it in GitHub Desktop.
SolutionGeneratedByLlm.java
private static void rotate(int[] arr, int steps) {
int minIndex = steps % arr.length;
if (minIndex < 0) {
minIndex += arr.length;
}
int[] result = new int[arr.length];
for (int i = 0; i < arr.length; i++) {
result[(i + minIndex) % arr.length] = arr[i];
}
System.arraycopy(result, 0, arr, 0, arr.length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment