Tap here to switch tabs
Problem
Submissions

Problem: Convert Number Words to Digits

med
30 min
Try to solve the Convert Number Words to Digits problem.

Statement

You are given a string s consisting of lowercase English letters.

Parse the string from left to right and identify valid English words representing single digits from "zero" to "nine" (specifically "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", and "nine"). Convert each identified word into its corresponding numeric digit from 00 to 99. Any characters or fragments that do not form a valid number word are ignored and skipped.

Return the resulting string of digits.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s contains only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Convert Number Words to Digits

med
30 min
Try to solve the Convert Number Words to Digits problem.

Statement

You are given a string s consisting of lowercase English letters.

Parse the string from left to right and identify valid English words representing single digits from "zero" to "nine" (specifically "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", and "nine"). Convert each identified word into its corresponding numeric digit from 00 to 99. Any characters or fragments that do not form a valid number word are ignored and skipped.

Return the resulting string of digits.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s contains only lowercase English letters.