Reconstruct Original Digits from English

Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order.

Example 1
Inputs = "owoztneoer"
Output"012"
The letters can be rearranged to form "zero", "one", and "two", so the digits are returned as 012.
Example 2
Inputs = "fviefuro"
Output"45"
The letters can be rearranged to form "four" and "five", so the digits are returned as 45.

Constraints

  • 1 <= s.length <= 10^5
  • s[i] is one of the characters ["e","g","f","i","h","o","n","s","r","u","t","w","v","x","z"].
  • s is guaranteed to be valid.

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate