This commit is contained in:
Max Schmitt 2024-10-22 11:42:31 +02:00
parent bd7ba9e200
commit 3147fbeb94
2 changed files with 7 additions and 5 deletions

View file

@ -20,10 +20,13 @@ export function findRepeatedSubsequences(s: string[]): { sequence: string[]; cou
let i = 0;
const arraysEqual = (a1: string[], a2: string[]) => {
if (a1.length !== a2.length) return false;
if (a1.length !== a2.length)
return false;
for (let j = 0; j < a1.length; j++) {
if (a1[j] !== a2[j]) return false;
if (a1[j] !== a2[j])
return false;
}
return true;
};
@ -41,9 +44,9 @@ export function findRepeatedSubsequences(s: string[]): { sequence: string[]; cou
while (
i + p * k <= n &&
arraysEqual(s.slice(i + p * (k - 1), i + p * k), substr)
) {
)
k += 1;
}
k -= 1; // Adjust k since it increments one extra time in the loop
// Update the maximal repeating substring if necessary

View file

@ -16,7 +16,6 @@
import path from 'path';
import { parseStackTraceLine } from '../utilsBundle';
import { isUnderTest } from './';
import type { StackFrame } from '@protocol/channels';
import { colors } from '../utilsBundle';
import { findRepeatedSubsequences } from './sequence';