欢迎光临散文网 会员登陆 & 注册

LeetCode 423. Reconstruct Original Digits from English

2023-05-06 16:10 作者:您是打尖儿还是住店呢  | 我要投稿

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

 

Example 1:

Input: s = "owoztneoer"Output: "012"

Example 2:

Input: s = "fviefuro"Output: "45"

 

Constraints:

  • 1 <= s.length <= 105

  • 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.

找呀找呀找规律;


这个是每个字符在数字中出线的信息,那么我们就要去根据专有的,去判断其他共用的信息;

就是加减法了;然后就过了。。

Runtime18 ms

Beats

20.31%

Memory43.3 MB

Beats

29.30%



LeetCode 423. Reconstruct Original Digits from English的评论 (共 条)

分享到微博请遵守国家法律