The Aho-Corasick algorithm is used for matching a set of strings in linear time. It builds a finite state machine that allows for efficient searching of multiple patterns simultaneously.
import { AhoCorasick } from "collection-kit";
import { AhoCorasick } from "collection-kit";
const ac = new AhoCorasick();
ac.build(["he", "she", "his", "hers"]);
const matches = ac.search("ushers");
console.log("Matches:", matches); // ["she", "he", "hers"]