Skip to content

Commit 7529d69

Browse files
committed
2019-11-30 423. Reconstruct Original Digits from English
1 parent 682c5db commit 7529d69

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
# @Author: 何睿
3+
# @Create Date: 2019-11-30 13:15:30
4+
# @Last Modified by: 何睿
5+
# @Last Modified time: 2019-11-30 13:28:08
6+
7+
8+
from collections import Counter
9+
10+
11+
class Solution:
12+
def originalDigits(self, s: str) -> str:
13+
res = {}
14+
count = Counter(s)
15+
for key, char in zip([0, 2, 4, 6, 8], ['z', 'w', 'u', 'x', 'g']):
16+
res[key] = count.get(char, 0)
17+
res[1] = count.get('o', 0) - res[0] - res[2] - res[4]
18+
res[3] = count.get('h', 0) - res[8]
19+
res[5] = count.get("f", 0) - res[4]
20+
res[7] = count.get('s', 0) - res[6]
21+
res[9] = count.get('i', 0) - res[6] - res[8] - res[5]
22+
23+
return ''.join(str(num) * res[num] for num in range(0, 10))

0 commit comments

Comments
 (0)