Reconstruct Digits from Jumbled English Words
Problem statement
A lowercase string is formed by concatenating zero or more English digit words (zero through nine) and arbitrarily shuffling all letters.
Return the original digits in ascending order. Repeated digit words are allowed. Return INVALID when the letters cannot be partitioned completely into digit words.
Function
reconstructEnglishDigits(letters: String) → StringExamples
Example 1
letters = "owoztneoer"return = "012"The letters form zero, one, and two.
Example 2
letters = "fviefuro"return = "45"The letters form four and five.
Example 3
letters = "abc"return = "INVALID"The letters cannot be consumed by digit words.
Constraints
0 <= letters.length <= 100000.letterscontains lowercase English letters.