Skip to content

Commit b23ca4e

Browse files
committed
Fix PMD violation: replace for loop with while loop
1 parent 5225cf4 commit b23ca4e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/com/thealgorithms/strings/KnuthMorrisPratt.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public static int[] computeLps(final String pattern) {
2626
final int[] lps = new int[n];
2727
int len = 0;
2828
lps[0] = 0;
29-
for (int i = 1; i < n;) {
29+
int i = 1;
30+
while (i < n) {
3031
if (pattern.charAt(i) == pattern.charAt(len)) {
3132
len++;
3233
lps[i] = len;

0 commit comments

Comments
 (0)