Check if an Original String Exists Given Two Encoded Strings
An original string, consisting of lowercase English letters, can be encoded by the following steps:
- Arbitrarily split it into a sequence of some number of non-empty substrings.
- Arbitrarily choose some elements, possibly none, of the sequence, and replace each with its length as a numeric string.
- Concatenate the sequence as the encoded string.
Given two encoded strings s1 and s2, consisting of lowercase English letters and digits 1-9 inclusive, return true if there exists an original string that could be encoded as both s1 and s2. Otherwise, return false.
Note: The test cases are generated such that the number of consecutive digits in s1 and s2 does not exceed 3.
Example 1
Input
s1 = "internationalization", s2 = "i18n"Output
trueIt is possible that "internationalization" was the original string, encoded directly as
s1 and as i18n for s2.Example 2
Input
s1 = "l123e", s2 = "44"Output
trueIt is possible that "leetcode" was the original string, encoded as
l123e for s1 and 44 for s2.Constraints
- 1 <= s1.length, s2.length <= 40
- s1 and s2 consist of digits 1-9 (inclusive), and lowercase English letters only.
- The number of consecutive digits in s1 and s2 does not exceed 3.