Assume you are designing a performance application to match keywords found in a url. What data structures / technologies would you employ to ensure a speedy (sub 10ns) algorithm that is able to match substrings against the URL?
To help shape your thinking, let's assume that we're dealing with a finite subset of words. This may help bound which algorithms would be most applicable for this problem.
Please also provide an actual code sample. It's always helpful to see a running example, but obviously doesn't need to be anything "production-ready."
- Tested locally in terminal with node
-
- node test.js
- Trie is the main data structure for the solution