Loading
Loading
A social media tool tries to make hashtags readable by splitting them back into words. A hashtag like sunsetbeach is readable if it can be cut into pieces that are all in the tool's word list.
Given the hashtag text (without the #) and the word list, return true if the whole text can be split into one or more listed words. A word may be used any number of times.
tag = "sunsetbeach", words = ["sun", "sunset", "set", "beach", "bea"]can_end[3] ← "sun"a split can end after suncan_end[6] ← "sunset" (or "set" after sun)two ways, one is enoughcan_end[9] ← "bea" after position 6a dead end, but markedcan_end[11] ← "beach" after position 6the whole tag splitstrueSign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n × W × L) time · O(n) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
sunset + beach, or sun + set + beach.
Example 2
After gone or go, the rest (fishing or nefishing) cannot be completed: ing is not a word.