To read hashtags aloud, a screen reader helper tries to split a hashtag's text tag (without the #) into words from a dictionary words. Each word may be used any number of times, and every character of tag must belong to some word.
Write canSplitTag(tag, words) that returns true if such a split exists, and false otherwise.
Input: tag = "darkmodetips", words = ["dark","mode","tips","tip"] Output: true
dark + mode + tips.
Input: tag = "darkmodes", words = ["dark","mode"] Output: false
After dark + mode, the final s is not a word.
1 <= tag.length <= 3001 <= words.length <= 10001 <= words[i].length <= 20Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #547 Split a Hashtag Into Known Words. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.