phrase and a list of words words. Check whether phrase can be produced by gluing together, with no spaces, the **first** k words of the list (in order) for some k from 1 to len(words).
Return True if it can, and False otherwise.phrase="sunnyday", words=["sun", "ny", "day", "off"] → True
"sun" + "ny" + "day" = "sunnyday", using the first three words.
phrase="sunnyday", words=["day", "sun", "ny"] → False
Gluing must start at the front of the list, and the first word is "day".
phrase="tea", words=["te", "ab"] → False
"te" is too short and "teab" is already too long, so exactly "tea" never appears.
phrase and the words consist of lowercase English lettersphrase="sunnyday", words=["sun", "ny", "day", "off"]
True
Run checks the first 3 tests in your browser. Submit checks all 127 tests on the server, hidden ones included.