Back to problems

Implement tag matcher and filesystem

Object-Oriented Programming · Harvey · Medium

Approach: Normalize the Sentence into a Word Set The core idea is to avoid rescanning the sentence for every tag. Since the only question we ever ask is “does this exact, normalized word occur in the sentence?”, we can preprocess the sentence into a hash set of whole-word tokens. After that, each tag lookup becomes an $$O(1)$$ membership check. Scan the sentence from left to right and collect maximal runs of letters and digits. Any other character, including spaces and…

Checking your access…