Solución
solution.tsTypeScript
export function kmpSearch(text: string, pattern: string): number[] {
// Escribe tu solución aquí
const regex = new RegExp(`(?=(${pattern}))`, 'g');
const matches = text.matchAll(regex);
const matchesArray = Array.from(matches);
const matchIndexes = matchesArray.map(match => match.index);
console.log(regex, matches, matchesArray, matchIndexes)
return matchIndexes;
}0respuestas