Similar idea. This is actually a mathematical problem. We want to figure out the number of digits, 0 - 9, that is, we have ten unknowns. Then according the letters of each English number and the total number of each letter in the given string, we can list 15 equations (because only 15 letters may appear in the English words for 0 to 9).
In conclusion, we have 15 equations and 10 unknowns and then we can solve it. The codes are just telling how to solve these linear equations.
Reconstruct Original Digits from English