Skip to main content
LeetCode 423, Medium. Topics: Hash Table, Math, String. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 22 parametrized pytest cases, and a playground notebook:

Problem

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

Examples

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.

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026