# LeetCode 423. Reconstruct Original Digits from English

public class Solution {
public String originalDigits(String s) {
int[] digits = new int[10];
for (int i = 0; i < s.length(); i++) {
switch(s.charAt(i)) {
case 'z': digits[0]++; break;
case 'x': digits[6]++; break;
case 's': digits[7]++; break; //7-6
case 'v': digits[5]++; break; //5-7
case 'g': digits[8]++; break;
case 'i': digits[9]++; break; //9-5-6-8
case 'h': digits[3]++; break; //3-8
case 'u': digits[4]++; break;
case 'w': digits[2]++; break;
case 'o': digits[1]++; break; //1-0-2-4
default: break;
}
}
digits[7] -= digits[6];
digits[5] -= digits[7];
digits[3] -= digits[8];
digits[9] -= digits[5] + digits[6] + digits[8];
digits[1] -= digits[0] + digits[2] + digits[4];
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 10; i++) {
for (int j = 0; j < digits[i]; j++) {
sb.append(i);
}
}
return sb.toString();
}
}

#### LeetCode 423. Reconstruct Original Digits from English 解题报告

2016-10-25 15:18:29

#### Reconstruct Original Digits from English

2016-10-19 08:45:58

#### 【LeetCode】 423. Reconstruct Original Digits from English

2017-01-09 00:48:35

#### Leetcode 423. Reconstruct Original Digits from English

2016-10-20 15:51:39

#### LeetCode 423. Reconstruct Original Digits from English

2017-01-23 13:36:44

#### [leetcode]423. Reconstruct Original Digits from English

2017-01-15 22:43:41

#### 【leetcode】423. Reconstruct Original Digits from English

2016-11-28 21:21:06

#### [leetcode] 423. Reconstruct Original Digits from English

2016-12-06 18:10:27

#### LeetCode - 423. Reconstruct Original Digits from English

2017-04-09 12:24:37