Exact Or Almost Certain
You must count the distinct substrings of a single string with characters, and the checker compares your number against an exact answer. Three plans are on the table:
- Hash every substring length by length, put the hashes in a set, add up the set sizes. Simple, and you already have a hashing template.
- Build a suffix array plus LCP array, answer with .
- Build a suffix automaton, sum over states of
len(v) - len(link(v)).
Which choice is right, and on what grounds?
Sign in to answer questions and track your progress
Sign In