Algorithm · Airbnb · Medium
You are given a string s together with an array of strings words. Wherever a substring of s is equal to one of the entries words[i], that part of s must be surrounded by a opening tag and a closing tag. The tagging follows these rules: Every occurrence of every word gets marked, and occurrences are allowed to overlap one another. When two marked intervals overlap or sit directly next to each other, they are combined so that a single ... pair covers the whole merged region.…