mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 06:23:08 +08:00
fix: change location of others to correct places (#5559)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
package com.thealgorithms.others;
|
||||
package com.thealgorithms.bitmanipulation;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -1,30 +0,0 @@
|
||||
package com.thealgorithms.others;
|
||||
|
||||
public final class ArrayRightRotation {
|
||||
private ArrayRightRotation() {
|
||||
}
|
||||
public static int[] rotateRight(int[] arr, int k) {
|
||||
if (arr == null || arr.length == 0 || k < 0) {
|
||||
throw new IllegalArgumentException("Invalid input");
|
||||
}
|
||||
|
||||
int n = arr.length;
|
||||
k = k % n; // Handle cases where k is larger than the array length
|
||||
|
||||
reverseArray(arr, 0, n - 1);
|
||||
reverseArray(arr, 0, k - 1);
|
||||
reverseArray(arr, k, n - 1);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
private static void reverseArray(int[] arr, int start, int end) {
|
||||
while (start < end) {
|
||||
int temp = arr[start];
|
||||
arr[start] = arr[end];
|
||||
arr[end] = temp;
|
||||
start++;
|
||||
end--;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.thealgorithms.others;
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.thealgorithms.others;
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.thealgorithms.others;
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.thealgorithms.others;
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
Reference in New Issue
Block a user