Created
September 26, 2024 15:59
-
-
Save maxiwer/a9b24cfde70858fed18db43bff549325 to your computer and use it in GitHub Desktop.
SolutionGeneratedByLlm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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