01Sorted suffixes, stored as numbers
A string of length n has n suffixes. The suffix array SA lists their starting indices in lexicographic order of the suffixes. For banana:
SA = [5, 3, 1, 0, 4, 2], meaning a < ana < anana < banana < na < nana.
You never store the suffixes themselves, only n integers, so memory is O(n).
The key property: all suffixes that start with a pattern P sit next to each other in sorted order. Find the first and last of them with two binary searches, each comparing up to |P| characters per step. That is O(m log n) per query, and the size of the block is the number of occurrences.