diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index ae10d1045dfe..f621c84dd4bf 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -138,9 +138,6 @@ - - - diff --git a/src/main/java/com/thealgorithms/others/BFPRT.java b/src/main/java/com/thealgorithms/others/BFPRT.java index 9e6fe6a3fbcc..1a5b44180651 100644 --- a/src/main/java/com/thealgorithms/others/BFPRT.java +++ b/src/main/java/com/thealgorithms/others/BFPRT.java @@ -34,9 +34,7 @@ public static int getMinKthByBFPRT(int[] arr, int k) { public static int[] copyArray(int[] arr) { int[] copyArr = new int[arr.length]; - for (int i = 0; i < arr.length; i++) { - copyArr[i] = arr[i]; - } + System.arraycopy(arr, 0, copyArr, 0, arr.length); return copyArr; } diff --git a/src/main/java/com/thealgorithms/others/BankersAlgorithm.java b/src/main/java/com/thealgorithms/others/BankersAlgorithm.java index baa180431ce4..a22d7c737415 100644 --- a/src/main/java/com/thealgorithms/others/BankersAlgorithm.java +++ b/src/main/java/com/thealgorithms/others/BankersAlgorithm.java @@ -60,10 +60,7 @@ static boolean checkSafeSystem(int[] processes, int[] availableArray, int[][] ma int[] safeSequenceArray = new int[totalProcess]; int[] workArray = new int[totalResources]; - - for (int i = 0; i < totalResources; i++) { - workArray[i] = availableArray[i]; - } + System.arraycopy(availableArray, 0, workArray, 0, totalResources); int count = 0; diff --git a/src/main/java/com/thealgorithms/others/ReturnSubsequence.java b/src/main/java/com/thealgorithms/others/ReturnSubsequence.java index 81bd051ca365..ef376c47a8f8 100644 --- a/src/main/java/com/thealgorithms/others/ReturnSubsequence.java +++ b/src/main/java/com/thealgorithms/others/ReturnSubsequence.java @@ -34,10 +34,8 @@ private static String[] returnSubsequence(String givenString) { // position=1 String[] ans = new String[2 * smallAns.length]; // Our answer will be an array off string of size=2*smallAns - int i = 0; - for (; i < smallAns.length; i++) { - ans[i] = smallAns[i]; // Copying all the strings present in smallAns to ans string array - } + System.arraycopy(smallAns, 0, ans, 0, smallAns.length); + for (int k = 0; k < smallAns.length; k++) { ans[k + smallAns.length] = givenString.charAt(0) + smallAns[k]; // Insert character at index=0 of the given // substring in front of every string diff --git a/src/main/java/com/thealgorithms/sorts/RadixSort.java b/src/main/java/com/thealgorithms/sorts/RadixSort.java index 847b94036ca9..a87097bf6e9d 100644 --- a/src/main/java/com/thealgorithms/sorts/RadixSort.java +++ b/src/main/java/com/thealgorithms/sorts/RadixSort.java @@ -35,9 +35,7 @@ private static void countSort(int[] arr, int n, int exp) { count[(arr[i] / exp) % 10]--; } - for (i = 0; i < n; i++) { - arr[i] = output[i]; - } + System.arraycopy(output, 0, arr, 0, n); } private static void radixsort(int[] arr, int n) {