|
@@ -0,0 +1,33 @@
|
|
|
+func originalDigits(s string) string {
|
|
|
+ freq, cnt := make([]int, 256), make([]int, 10)
|
|
|
+ for _, r := range s {
|
|
|
+ freq[r]++
|
|
|
+ }
|
|
|
+ cnt[0] = wordCnt(freq, 'z', "o")
|
|
|
+ cnt[2] = wordCnt(freq, 'w', "o")
|
|
|
+ cnt[4] = wordCnt(freq, 'u', "fo")
|
|
|
+ cnt[6] = wordCnt(freq, 'x', "s")
|
|
|
+ cnt[8] = wordCnt(freq, 'g', "h")
|
|
|
+ //
|
|
|
+ cnt[1] = wordCnt(freq, 'o', "n")
|
|
|
+ cnt[3] = freq['h']
|
|
|
+ cnt[5] = freq['f']
|
|
|
+ cnt[7] = wordCnt(freq, 's', "n")
|
|
|
+ //
|
|
|
+ cnt[9] = freq['n'] / 2
|
|
|
+ var sb strings.Builder
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+ for j := 0; j < cnt[i]; j++ {
|
|
|
+ sb.WriteByte(byte(i + '0'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sb.String()
|
|
|
+}
|
|
|
+
|
|
|
+func wordCnt(freq []int, key byte, word string) int {
|
|
|
+ cnt := freq[key]
|
|
|
+ for _, r := range word {
|
|
|
+ freq[r] -= cnt
|
|
|
+ }
|
|
|
+ return cnt
|
|
|
+}
|