From 54c214cdb04062565b55ae7d8aefd3828671bf60 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 15:42:59 +0530 Subject: [PATCH 01/32] Add array rotation utility using reversal algorithm --- .../thealgorithms/others/ArrayRotation.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/main/java/com/thealgorithms/others/ArrayRotation.java diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java new file mode 100644 index 000000000000..cd0b18595824 --- /dev/null +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -0,0 +1,85 @@ +package com.thealgorithms.others; + +import java.util.Arrays; + +/** + * Array Rotation Utility + * + * Supports: + * 1. Left Rotation + * 2. Right Rotation + * + * Approach: + * Reversal Algorithm + * + * Time Complexity: O(n) + * Space Complexity: O(1) + */ + +public class ArrayRotation { + + /** + * Rotates the array to the right by k positions. + * + * @param nums the input array + * @param k number of rotations + */ + + public static void rotateRight(int[] nums, int k) { + + int n = nums.length; + + if (n == 0) { + return; + } + + k = k % n; + + reverse(nums, 0, n - 1); + reverse(nums, 0, k - 1); + reverse(nums, k, n - 1); + + } + + /** + * Rotates the array to the left by k positions. + * + * @param nums the input array + * @param k number of rotations + */ + + public static void rotateLeft(int[] nums, int k) { + + int n = nums.length; + + if (n == 0) { + return; + } + + k = k % n; + + reverse(nums, 0, k - 1); + reverse(nums, k, n - 1); + reverse(nums, 0, n - 1); + } + + /** + * Reverses elements between start and end indices. + * + * @param nums the input array + * @param start starting index + * @param end ending index + */ + private static void reverse(int[] nums, int start, int end) { + + while (start < end) { + + int temp = nums[start]; + nums[start] = nums[end]; + nums[end] = temp; + + start++; + end--; + } + } +} From cb3fea7e0d1f878e4aeda212181d83ad7fe40720 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 19:21:19 +0530 Subject: [PATCH 02/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index cd0b18595824..be1bf2f27ec4 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -1,7 +1,5 @@ package com.thealgorithms.others; -import java.util.Arrays; - /** * Array Rotation Utility * @@ -18,6 +16,9 @@ public class ArrayRotation { + private ArrayRotation() { + } + /** * Rotates the array to the right by k positions. * From 8376bbe526de19126b9c50cd76449a7669badb4f Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 19:37:53 +0530 Subject: [PATCH 03/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index be1bf2f27ec4..3e2f8c57ceef 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -39,7 +39,6 @@ public static void rotateRight(int[] nums, int k) { reverse(nums, 0, n - 1); reverse(nums, 0, k - 1); reverse(nums, k, n - 1); - } /** From df2db03072fb652fa282aa322d743c3b6c521f28 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 19:42:37 +0530 Subject: [PATCH 04/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 3e2f8c57ceef..7ef4c3472b95 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -13,7 +13,6 @@ * Time Complexity: O(n) * Space Complexity: O(1) */ - public class ArrayRotation { private ArrayRotation() { @@ -25,7 +24,6 @@ private ArrayRotation() { * @param nums the input array * @param k number of rotations */ - public static void rotateRight(int[] nums, int k) { int n = nums.length; @@ -47,7 +45,6 @@ public static void rotateRight(int[] nums, int k) { * @param nums the input array * @param k number of rotations */ - public static void rotateLeft(int[] nums, int k) { int n = nums.length; @@ -82,4 +79,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } -} +} \ No newline at end of file From d729f7b42171837d52bb92ed2387e3e891d25de2 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 19:51:25 +0530 Subject: [PATCH 05/32] Fix checkstyle issues --- .../thealgorithms/others/ArrayRotation.java | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 7ef4c3472b95..804ddb8de384 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -15,68 +15,68 @@ */ public class ArrayRotation { - private ArrayRotation() { - } + private ArrayRotation() { + } - /** - * Rotates the array to the right by k positions. - * - * @param nums the input array - * @param k number of rotations - */ - public static void rotateRight(int[] nums, int k) { + /** + * Rotates the array to the right by k positions. + * + * @param nums the input array + * @param k number of rotations + */ + public static void rotateRight(int[] nums, int k) { - int n = nums.length; + int n = nums.length; - if (n == 0) { - return; - } + if (n == 0) { + return; + } - k = k % n; + k = k % n; - reverse(nums, 0, n - 1); - reverse(nums, 0, k - 1); - reverse(nums, k, n - 1); - } + reverse(nums, 0, n - 1); + reverse(nums, 0, k - 1); + reverse(nums, k, n - 1); + } - /** - * Rotates the array to the left by k positions. - * - * @param nums the input array - * @param k number of rotations - */ - public static void rotateLeft(int[] nums, int k) { + /** + * Rotates the array to the left by k positions. + * + * @param nums the input array + * @param k number of rotations + */ + public static void rotateLeft(int[] nums, int k) { - int n = nums.length; + int n = nums.length; - if (n == 0) { - return; - } + if (n == 0) { + return; + } - k = k % n; + k = k % n; - reverse(nums, 0, k - 1); - reverse(nums, k, n - 1); - reverse(nums, 0, n - 1); - } + reverse(nums, 0, k - 1); + reverse(nums, k, n - 1); + reverse(nums, 0, n - 1); + } - /** - * Reverses elements between start and end indices. - * - * @param nums the input array - * @param start starting index - * @param end ending index - */ - private static void reverse(int[] nums, int start, int end) { + /** + * Reverses elements between start and end indices. + * + * @param nums the input array + * @param start starting index + * @param end ending index + */ + private static void reverse(int[] nums, int start, int end) { - while (start < end) { + while (start < end) { - int temp = nums[start]; - nums[start] = nums[end]; - nums[end] = temp; + int temp = nums[start]; + nums[start] = nums[end]; + nums[end] = temp; - start++; - end--; + start++; + end--; + } } - } } \ No newline at end of file From e3d8cb133530d2be7d7b01de2a03e1dc404e9ff5 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 19:53:48 +0530 Subject: [PATCH 06/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 804ddb8de384..9d4f3663d3c9 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -79,4 +79,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } -} \ No newline at end of file + } \ No newline at end of file From 3fc7f458abf144c752eb775394879bdf30fcd311 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 19:55:30 +0530 Subject: [PATCH 07/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 9d4f3663d3c9..64df6d7380f4 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -79,4 +79,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } - } \ No newline at end of file + } \ No newline at end of file From 8831d241a19c4a8b7ed23cce512a8d19f85a1a4f Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 19:57:11 +0530 Subject: [PATCH 08/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 64df6d7380f4..804ddb8de384 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -79,4 +79,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } - } \ No newline at end of file +} \ No newline at end of file From 0940d5eb55281fe81a1a11fed4aa43e71af3463a Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:00:59 +0530 Subject: [PATCH 09/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 804ddb8de384..e82128c3e3cd 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -79,4 +79,5 @@ private static void reverse(int[] nums, int start, int end) { end--; } } + } \ No newline at end of file From 4adc28c71d0a9eb5085c1297bfaeb37c3545fd57 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:02:57 +0530 Subject: [PATCH 10/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index e82128c3e3cd..4241f9c2811b 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -78,6 +78,5 @@ private static void reverse(int[] nums, int start, int end) { start++; end--; } - } - -} \ No newline at end of file + } + } \ No newline at end of file From f28d8fc6080e5a44cbac02451e7418024cfa1efe Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:06:26 +0530 Subject: [PATCH 11/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 4241f9c2811b..804ddb8de384 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -78,5 +78,5 @@ private static void reverse(int[] nums, int start, int end) { start++; end--; } - } - } \ No newline at end of file + } +} \ No newline at end of file From d1152ce0d495846003ce05157d63cf958fff6508 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:08:55 +0530 Subject: [PATCH 12/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 804ddb8de384..9d4f3663d3c9 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -79,4 +79,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } -} \ No newline at end of file + } \ No newline at end of file From 52a57dd1e7f1a0771321ae16175fd59b60b89934 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:10:37 +0530 Subject: [PATCH 13/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 9d4f3663d3c9..ab42cb3a2593 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -79,4 +79,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } - } \ No newline at end of file + } \ No newline at end of file From f81884d698b9f7ecffba44d1f24810e1b83205d6 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:12:02 +0530 Subject: [PATCH 14/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index ab42cb3a2593..64df6d7380f4 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -79,4 +79,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } - } \ No newline at end of file + } \ No newline at end of file From 43731f0b52385ad8d6fd04db7c698d50c9a3ec91 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:14:58 +0530 Subject: [PATCH 15/32] Fix checkstyle issues --- .../java/com/thealgorithms/others/ArrayRotation.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 64df6d7380f4..31d7b145e49c 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -22,10 +22,9 @@ private ArrayRotation() { * Rotates the array to the right by k positions. * * @param nums the input array - * @param k number of rotations + * @param k number of rotations */ public static void rotateRight(int[] nums, int k) { - int n = nums.length; if (n == 0) { @@ -43,10 +42,9 @@ public static void rotateRight(int[] nums, int k) { * Rotates the array to the left by k positions. * * @param nums the input array - * @param k number of rotations + * @param k number of rotations */ public static void rotateLeft(int[] nums, int k) { - int n = nums.length; if (n == 0) { @@ -65,12 +63,10 @@ public static void rotateLeft(int[] nums, int k) { * * @param nums the input array * @param start starting index - * @param end ending index + * @param end ending index */ private static void reverse(int[] nums, int start, int end) { - while (start < end) { - int temp = nums[start]; nums[start] = nums[end]; nums[end] = temp; @@ -79,4 +75,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } - } \ No newline at end of file +} \ No newline at end of file From bb2df0076be66cfec1bf9e219adc2574c1a6adfa Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:17:21 +0530 Subject: [PATCH 16/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 31d7b145e49c..6899a41ec151 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -75,4 +75,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } -} \ No newline at end of file + } \ No newline at end of file From a21bed0a352354f19e32cf5e080f1b95efb2bf7e Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:19:05 +0530 Subject: [PATCH 17/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 6899a41ec151..a0e9b5c6f955 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -74,5 +74,5 @@ private static void reverse(int[] nums, int start, int end) { start++; end--; } - } - } \ No newline at end of file + } + } \ No newline at end of file From f9e24d0696cbd140e70d2374e048a7402202266f Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:21:46 +0530 Subject: [PATCH 18/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index a0e9b5c6f955..8afd5abbef14 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -61,7 +61,7 @@ public static void rotateLeft(int[] nums, int k) { /** * Reverses elements between start and end indices. * - * @param nums the input array + * @param nums the input array * @param start starting index * @param end ending index */ @@ -74,5 +74,5 @@ private static void reverse(int[] nums, int start, int end) { start++; end--; } - } - } \ No newline at end of file + } +} \ No newline at end of file From a18a7c816fd11800d487e76040d1237baa0072a4 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:23:37 +0530 Subject: [PATCH 19/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index 8afd5abbef14..e339e98aa7f3 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -75,4 +75,4 @@ private static void reverse(int[] nums, int start, int end) { end--; } } -} \ No newline at end of file +} From 6a7d2c72c694c5436d9bc07979147f7de86ad040 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Wed, 13 May 2026 20:26:58 +0530 Subject: [PATCH 20/32] Fix checkstyle issues --- src/main/java/com/thealgorithms/others/ArrayRotation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/others/ArrayRotation.java b/src/main/java/com/thealgorithms/others/ArrayRotation.java index e339e98aa7f3..7e3f93d3a9d0 100644 --- a/src/main/java/com/thealgorithms/others/ArrayRotation.java +++ b/src/main/java/com/thealgorithms/others/ArrayRotation.java @@ -13,7 +13,7 @@ * Time Complexity: O(n) * Space Complexity: O(1) */ -public class ArrayRotation { +public final class ArrayRotation { private ArrayRotation() { } From 81d90cf0eaa892a72aabbf4cb3af8e662aa1b863 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:08:01 +0530 Subject: [PATCH 21/32] Add unit tests for ArrayRotation --- .../others/ArrayRotationTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/main/java/com/thealgorithms/others/ArrayRotationTest.java diff --git a/src/main/java/com/thealgorithms/others/ArrayRotationTest.java b/src/main/java/com/thealgorithms/others/ArrayRotationTest.java new file mode 100644 index 000000000000..356a683be468 --- /dev/null +++ b/src/main/java/com/thealgorithms/others/ArrayRotationTest.java @@ -0,0 +1,62 @@ +package com.thealgorithms.others; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +import org.junit.jupiter.api.Test; + +public class ArrayRotationTest { + + @Test + void shouldRotateArrayRightByTwoPositions() { + int[] values = {1, 2, 3, 4, 5}; + + ArrayRotation.rotateRight(values, 2); + + assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); + } + + @Test + void shouldRotateArrayLeftByTwoPositions() { + int[] values = {1, 2, 3, 4, 5}; + + ArrayRotation.rotateLeft(values, 2); + + assertArrayEquals(new int[] {3, 4, 5, 1, 2}, values); + } + + @Test + void shouldHandleRotationGreaterThanArrayLength() { + int[] values = {10, 20, 30, 40}; + + ArrayRotation.rotateRight(values, 6); + + assertArrayEquals(new int[] {30, 40, 10, 20}, values); + } + + @Test + void shouldKeepSingleElementArrayUnchanged() { + int[] values = {99}; + + ArrayRotation.rotateLeft(values, 5); + + assertArrayEquals(new int[] {99}, values); + } + + @Test + void shouldHandleEmptyArrayWithoutErrors() { + int[] values = {}; + + ArrayRotation.rotateRight(values, 3); + + assertArrayEquals(new int[] {}, values); + } + + @Test + void shouldReturnOriginalArrayWhenRotationIsZero() { + int[] values = {7, 8, 9}; + + ArrayRotation.rotateLeft(values, 0); + + assertArrayEquals(new int[] {7, 8, 9}, values); + } +} \ No newline at end of file From c11d0ca6fd0c0d5ceba034932ae02e49f2429e22 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:14:05 +0530 Subject: [PATCH 22/32] Add unit tests for array rotation utility --- .../others/ArrayRotationTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/test/java/com/thealgorithms/others/ArrayRotationTest.java diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java new file mode 100644 index 000000000000..283613d92d23 --- /dev/null +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -0,0 +1,62 @@ +package com.thealgorithms.others; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +import org.junit.jupiter.api.Test; + +public class ArrayRotationTest { + + @Test + void shouldRotateArrayRightByTwoPositions() { + int[] values = { 1, 2, 3, 4, 5 }; + + ArrayRotation.rotateRight(values, 2); + + assertArrayEquals(new int[] { 4, 5, 1, 2, 3 }, values); + } + + @Test + void shouldRotateArrayLeftByTwoPositions() { + int[] values = { 1, 2, 3, 4, 5 }; + + ArrayRotation.rotateLeft(values, 2); + + assertArrayEquals(new int[] { 3, 4, 5, 1, 2 }, values); + } + + @Test + void shouldHandleRotationGreaterThanArrayLength() { + int[] values = { 10, 20, 30, 40 }; + + ArrayRotation.rotateRight(values, 6); + + assertArrayEquals(new int[] { 30, 40, 10, 20 }, values); + } + + @Test + void shouldKeepSingleElementArrayUnchanged() { + int[] values = { 99 }; + + ArrayRotation.rotateLeft(values, 5); + + assertArrayEquals(new int[] { 99 }, values); + } + + @Test + void shouldHandleEmptyArrayWithoutErrors() { + int[] values = {}; + + ArrayRotation.rotateRight(values, 3); + + assertArrayEquals(new int[] {}, values); + } + + @Test + void shouldReturnOriginalArrayWhenRotationIsZero() { + int[] values = { 7, 8, 9 }; + + ArrayRotation.rotateLeft(values, 0); + + assertArrayEquals(new int[] { 7, 8, 9 }, values); + } +} From 02893973cd4e97380febc3cc591efb001ce630cd Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:15:48 +0530 Subject: [PATCH 23/32] Add unit tests for array rotation utility --- .../java/com/thealgorithms/others/ArrayLeftRotationTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java index b31b7d825ed5..fe1655e1bae7 100644 --- a/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java @@ -52,3 +52,4 @@ void testForEmptyArray() { assertArrayEquals(arr, result); } } + From 1226614683c658aa5d38f1553e1921595ea5cb1c Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:18:05 +0530 Subject: [PATCH 24/32] Fix formatting in ArrayRotation tests --- .../others/ArrayLeftRotationTest.java | 67 ++++++++++--------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java index fe1655e1bae7..f43448483021 100644 --- a/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java @@ -4,52 +4,59 @@ import org.junit.jupiter.api.Test; -class ArrayLeftRotationTest { +public class ArrayRotationTest { @Test - void testForOneElement() { - int[] arr = {3}; - int[] result = ArrayLeftRotation.rotateLeft(arr, 3); - assertArrayEquals(arr, result); + void shouldRotateArrayRightByTwoPositions() { + int[] values = {1, 2, 3, 4, 5}; + + ArrayRotation.rotateRight(values, 2); + + assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); } @Test - void testForZeroStep() { - int[] arr = {3, 1, 5, 8, 6}; - int[] result = ArrayLeftRotation.rotateLeft(arr, 0); - assertArrayEquals(arr, result); + void shouldRotateArrayLeftByTwoPositions() { + int[] values = {1, 2, 3, 4, 5}; + + ArrayRotation.rotateLeft(values, 2); + + assertArrayEquals(new int[] {3, 4, 5, 1, 2}, values); } @Test - void testForEqualSizeStep() { - int[] arr = {3, 1, 5, 8, 6}; - int[] result = ArrayLeftRotation.rotateLeft(arr, 5); - assertArrayEquals(arr, result); + void shouldHandleRotationGreaterThanArrayLength() { + int[] values = {10, 20, 30, 40}; + + ArrayRotation.rotateRight(values, 6); + + assertArrayEquals(new int[] {30, 40, 10, 20}, values); } @Test - void testForLowerSizeStep() { - int[] arr = {3, 1, 5, 8, 6}; - int n = 2; - int[] expected = {5, 8, 6, 3, 1}; - int[] result = ArrayLeftRotation.rotateLeft(arr, n); - assertArrayEquals(expected, result); + void shouldKeepSingleElementArrayUnchanged() { + int[] values = {99}; + + ArrayRotation.rotateLeft(values, 5); + + assertArrayEquals(new int[] {99}, values); } @Test - void testForHigherSizeStep() { - int[] arr = {3, 1, 5, 8, 6}; - int n = 7; - int[] expected = {5, 8, 6, 3, 1}; - int[] result = ArrayLeftRotation.rotateLeft(arr, n); - assertArrayEquals(expected, result); + void shouldHandleEmptyArrayWithoutErrors() { + int[] values = {}; + + ArrayRotation.rotateRight(values, 3); + + assertArrayEquals(new int[] {}, values); } @Test - void testForEmptyArray() { - int[] arr = {}; - int[] result = ArrayLeftRotation.rotateLeft(arr, 3); - assertArrayEquals(arr, result); + void shouldReturnOriginalArrayWhenRotationIsZero() { + int[] values = {7, 8, 9}; + + ArrayRotation.rotateLeft(values, 0); + + assertArrayEquals(new int[] {7, 8, 9}, values); } } - From 1f4bc30cc1465266ced230ee3d8eccb9bda4d82d Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:21:16 +0530 Subject: [PATCH 25/32] Fix formatting in ArrayRotation tests --- .../others/ArrayLeftRotationTest.java | 66 ++++++++----------- .../others/ArrayRotationTest.java | 20 +++--- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java index f43448483021..b31b7d825ed5 100644 --- a/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayLeftRotationTest.java @@ -4,59 +4,51 @@ import org.junit.jupiter.api.Test; -public class ArrayRotationTest { +class ArrayLeftRotationTest { @Test - void shouldRotateArrayRightByTwoPositions() { - int[] values = {1, 2, 3, 4, 5}; - - ArrayRotation.rotateRight(values, 2); - - assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); + void testForOneElement() { + int[] arr = {3}; + int[] result = ArrayLeftRotation.rotateLeft(arr, 3); + assertArrayEquals(arr, result); } @Test - void shouldRotateArrayLeftByTwoPositions() { - int[] values = {1, 2, 3, 4, 5}; - - ArrayRotation.rotateLeft(values, 2); - - assertArrayEquals(new int[] {3, 4, 5, 1, 2}, values); + void testForZeroStep() { + int[] arr = {3, 1, 5, 8, 6}; + int[] result = ArrayLeftRotation.rotateLeft(arr, 0); + assertArrayEquals(arr, result); } @Test - void shouldHandleRotationGreaterThanArrayLength() { - int[] values = {10, 20, 30, 40}; - - ArrayRotation.rotateRight(values, 6); - - assertArrayEquals(new int[] {30, 40, 10, 20}, values); + void testForEqualSizeStep() { + int[] arr = {3, 1, 5, 8, 6}; + int[] result = ArrayLeftRotation.rotateLeft(arr, 5); + assertArrayEquals(arr, result); } @Test - void shouldKeepSingleElementArrayUnchanged() { - int[] values = {99}; - - ArrayRotation.rotateLeft(values, 5); - - assertArrayEquals(new int[] {99}, values); + void testForLowerSizeStep() { + int[] arr = {3, 1, 5, 8, 6}; + int n = 2; + int[] expected = {5, 8, 6, 3, 1}; + int[] result = ArrayLeftRotation.rotateLeft(arr, n); + assertArrayEquals(expected, result); } @Test - void shouldHandleEmptyArrayWithoutErrors() { - int[] values = {}; - - ArrayRotation.rotateRight(values, 3); - - assertArrayEquals(new int[] {}, values); + void testForHigherSizeStep() { + int[] arr = {3, 1, 5, 8, 6}; + int n = 7; + int[] expected = {5, 8, 6, 3, 1}; + int[] result = ArrayLeftRotation.rotateLeft(arr, n); + assertArrayEquals(expected, result); } @Test - void shouldReturnOriginalArrayWhenRotationIsZero() { - int[] values = {7, 8, 9}; - - ArrayRotation.rotateLeft(values, 0); - - assertArrayEquals(new int[] {7, 8, 9}, values); + void testForEmptyArray() { + int[] arr = {}; + int[] result = ArrayLeftRotation.rotateLeft(arr, 3); + assertArrayEquals(arr, result); } } diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java index 283613d92d23..f43448483021 100644 --- a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -8,38 +8,38 @@ public class ArrayRotationTest { @Test void shouldRotateArrayRightByTwoPositions() { - int[] values = { 1, 2, 3, 4, 5 }; + int[] values = {1, 2, 3, 4, 5}; ArrayRotation.rotateRight(values, 2); - assertArrayEquals(new int[] { 4, 5, 1, 2, 3 }, values); + assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); } @Test void shouldRotateArrayLeftByTwoPositions() { - int[] values = { 1, 2, 3, 4, 5 }; + int[] values = {1, 2, 3, 4, 5}; ArrayRotation.rotateLeft(values, 2); - assertArrayEquals(new int[] { 3, 4, 5, 1, 2 }, values); + assertArrayEquals(new int[] {3, 4, 5, 1, 2}, values); } @Test void shouldHandleRotationGreaterThanArrayLength() { - int[] values = { 10, 20, 30, 40 }; + int[] values = {10, 20, 30, 40}; ArrayRotation.rotateRight(values, 6); - assertArrayEquals(new int[] { 30, 40, 10, 20 }, values); + assertArrayEquals(new int[] {30, 40, 10, 20}, values); } @Test void shouldKeepSingleElementArrayUnchanged() { - int[] values = { 99 }; + int[] values = {99}; ArrayRotation.rotateLeft(values, 5); - assertArrayEquals(new int[] { 99 }, values); + assertArrayEquals(new int[] {99}, values); } @Test @@ -53,10 +53,10 @@ void shouldHandleEmptyArrayWithoutErrors() { @Test void shouldReturnOriginalArrayWhenRotationIsZero() { - int[] values = { 7, 8, 9 }; + int[] values = {7, 8, 9}; ArrayRotation.rotateLeft(values, 0); - assertArrayEquals(new int[] { 7, 8, 9 }, values); + assertArrayEquals(new int[] {7, 8, 9}, values); } } From ba42f82eeef488da6bb41191b533dc0501c6fe7e Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:23:33 +0530 Subject: [PATCH 26/32] Fix formatting in ArrayRotation tests --- src/test/java/com/thealgorithms/others/ArrayRotationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java index f43448483021..a8570f2cf68f 100644 --- a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -59,4 +59,5 @@ void shouldReturnOriginalArrayWhenRotationIsZero() { assertArrayEquals(new int[] {7, 8, 9}, values); } -} + } + From 2eb72d9d8c4143e1f54b2174e6a6ef8fb9ec4d43 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:33:52 +0530 Subject: [PATCH 27/32] Fix formatting in ArrayRotation tests --- .../others/ArrayRotationTest.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java index a8570f2cf68f..0d00b74a0c93 100644 --- a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -8,38 +8,40 @@ public class ArrayRotationTest { @Test void shouldRotateArrayRightByTwoPositions() { - int[] values = {1, 2, 3, 4, 5}; + int[] values = { 1, 2, 3, 4, 5 }; ArrayRotation.rotateRight(values, 2); - assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); + assertArrayEquals(new int[] { 4, 5, 1, 2, 3 }, values); + } @Test void shouldRotateArrayLeftByTwoPositions() { - int[] values = {1, 2, 3, 4, 5}; + int[] values = { 1, 2, 3, 4, 5 }; ArrayRotation.rotateLeft(values, 2); - assertArrayEquals(new int[] {3, 4, 5, 1, 2}, values); + assertArrayEquals(new int[] { 3, 4, 5, 1, 2 }, values); + } @Test void shouldHandleRotationGreaterThanArrayLength() { - int[] values = {10, 20, 30, 40}; + int[] values = { 10, 20, 30, 40 }; - ArrayRotation.rotateRight(values, 6); + ArrayRotation.rotateRight(values, 2); - assertArrayEquals(new int[] {30, 40, 10, 20}, values); + assertArrayEquals(new int[] { 30, 40, 10, 20 }, values); } @Test void shouldKeepSingleElementArrayUnchanged() { - int[] values = {99}; + int[] values = { 99 }; ArrayRotation.rotateLeft(values, 5); - assertArrayEquals(new int[] {99}, values); + assertArrayEquals(new int[] { 99 }, values); } @Test @@ -53,11 +55,10 @@ void shouldHandleEmptyArrayWithoutErrors() { @Test void shouldReturnOriginalArrayWhenRotationIsZero() { - int[] values = {7, 8, 9}; + int[] values = { 7, 8, 9 }; ArrayRotation.rotateLeft(values, 0); - assertArrayEquals(new int[] {7, 8, 9}, values); + assertArrayEquals(new int[] { 7, 8, 9 }, values); } - } - +} From 5e672206b84ff854d6204365440ea18fa7131d3b Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:37:39 +0530 Subject: [PATCH 28/32] Fix formatting in ArrayRotation tests --- .../thealgorithms/others/ArrayRotationTest.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java index 0d00b74a0c93..39d59c1aebfd 100644 --- a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -12,36 +12,36 @@ void shouldRotateArrayRightByTwoPositions() { ArrayRotation.rotateRight(values, 2); - assertArrayEquals(new int[] { 4, 5, 1, 2, 3 }, values); + assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); } @Test void shouldRotateArrayLeftByTwoPositions() { - int[] values = { 1, 2, 3, 4, 5 }; + int[] values = {1, 2, 3, 4, 5}; ArrayRotation.rotateLeft(values, 2); - assertArrayEquals(new int[] { 3, 4, 5, 1, 2 }, values); + assertArrayEquals(new int[] {3, 4, 5, 1, 2}, values); } @Test void shouldHandleRotationGreaterThanArrayLength() { - int[] values = { 10, 20, 30, 40 }; + int[] values = {10, 20, 30, 40}; ArrayRotation.rotateRight(values, 2); - assertArrayEquals(new int[] { 30, 40, 10, 20 }, values); + assertArrayEquals(new int[] {30, 40, 10, 20}, values); } @Test void shouldKeepSingleElementArrayUnchanged() { - int[] values = { 99 }; + int[] values = {99}; ArrayRotation.rotateLeft(values, 5); - assertArrayEquals(new int[] { 99 }, values); + assertArrayEquals(new int[] {99}, values); } @Test @@ -59,6 +59,7 @@ void shouldReturnOriginalArrayWhenRotationIsZero() { ArrayRotation.rotateLeft(values, 0); - assertArrayEquals(new int[] { 7, 8, 9 }, values); + assertArrayEquals(new int[] {7, 8, 9}, values); } } + From 47aa448a234e769f5504fee5308cb954efed77cf Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:39:23 +0530 Subject: [PATCH 29/32] Fix formatting in ArrayRotation tests --- .../java/com/thealgorithms/others/ArrayRotationTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java index 39d59c1aebfd..ac23f433bab2 100644 --- a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -8,12 +8,11 @@ public class ArrayRotationTest { @Test void shouldRotateArrayRightByTwoPositions() { - int[] values = { 1, 2, 3, 4, 5 }; + int[] values = {1, 2, 3, 4, 5}; ArrayRotation.rotateRight(values, 2); assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); - } @Test @@ -23,7 +22,6 @@ void shouldRotateArrayLeftByTwoPositions() { ArrayRotation.rotateLeft(values, 2); assertArrayEquals(new int[] {3, 4, 5, 1, 2}, values); - } @Test @@ -61,5 +59,5 @@ void shouldReturnOriginalArrayWhenRotationIsZero() { assertArrayEquals(new int[] {7, 8, 9}, values); } -} + } From c278b2d781dece10474e190d5d0bb8168bcdd23b Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:41:31 +0530 Subject: [PATCH 30/32] Fix formatting in ArrayRotation tests --- .../java/com/thealgorithms/others/ArrayRotationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java index ac23f433bab2..4ea0eda7d2b3 100644 --- a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -13,7 +13,7 @@ void shouldRotateArrayRightByTwoPositions() { ArrayRotation.rotateRight(values, 2); assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); - } + } @Test void shouldRotateArrayLeftByTwoPositions() { @@ -49,11 +49,11 @@ void shouldHandleEmptyArrayWithoutErrors() { ArrayRotation.rotateRight(values, 3); assertArrayEquals(new int[] {}, values); - } + } @Test void shouldReturnOriginalArrayWhenRotationIsZero() { - int[] values = { 7, 8, 9 }; + int[] values = {7, 8, 9}; ArrayRotation.rotateLeft(values, 0); From e6393ac2c6cb991cec9adbbdcf98054329805613 Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:44:07 +0530 Subject: [PATCH 31/32] Fix formatting in ArrayRotation tests --- .../java/com/thealgorithms/others/ArrayRotationTest.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java index 4ea0eda7d2b3..f43448483021 100644 --- a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -13,7 +13,7 @@ void shouldRotateArrayRightByTwoPositions() { ArrayRotation.rotateRight(values, 2); assertArrayEquals(new int[] {4, 5, 1, 2, 3}, values); - } + } @Test void shouldRotateArrayLeftByTwoPositions() { @@ -28,7 +28,7 @@ void shouldRotateArrayLeftByTwoPositions() { void shouldHandleRotationGreaterThanArrayLength() { int[] values = {10, 20, 30, 40}; - ArrayRotation.rotateRight(values, 2); + ArrayRotation.rotateRight(values, 6); assertArrayEquals(new int[] {30, 40, 10, 20}, values); } @@ -49,7 +49,7 @@ void shouldHandleEmptyArrayWithoutErrors() { ArrayRotation.rotateRight(values, 3); assertArrayEquals(new int[] {}, values); - } + } @Test void shouldReturnOriginalArrayWhenRotationIsZero() { @@ -59,5 +59,4 @@ void shouldReturnOriginalArrayWhenRotationIsZero() { assertArrayEquals(new int[] {7, 8, 9}, values); } - } - +} From cf56a809c86ce5546bd867985dfc2f4005d7e49e Mon Sep 17 00:00:00 2001 From: bhanu1012 Date: Sun, 17 May 2026 20:50:32 +0530 Subject: [PATCH 32/32] Fix formatting in ArrayRotation tests --- src/test/java/com/thealgorithms/others/ArrayRotationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java index f43448483021..5e77bde45c4a 100644 --- a/src/test/java/com/thealgorithms/others/ArrayRotationTest.java +++ b/src/test/java/com/thealgorithms/others/ArrayRotationTest.java @@ -59,4 +59,4 @@ void shouldReturnOriginalArrayWhenRotationIsZero() { assertArrayEquals(new int[] {7, 8, 9}, values); } -} + }