abcdefg can be split into ab, cde, f, g, and replacing the second and third pieces gives ab31g.
You are given two shorthands first and second made of lowercase English letters and the digits 1 to 9. Return True if some word could produce both of them, and False otherwise.
Note that a run of digits is not necessarily a single number: 31 may stand for one piece of length 31 or for two pieces of lengths 3 and 1.first="k8s", second="kuber4es" → False
The word kubernetes fits: k8s replaces the eight letters ubernete with a number, and kuber4es replaces the four letters nete.
first="a11", second="2b" → True
11 may be read as two one-letter pieces (1 and 1). Then a word such as axb fits: three letters, starting with a and ending with b.
first="ab3", second="2c1" → False
The first shorthand describes a 5-letter word, the second a 4-letter one, so no word fits both.
1 to 9first="k8s", second="kuber4es"
False
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.