Problem
Code
import java.util.*;
class Solution {
public int solution(String s) {
String[] engArr = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
String result = "";
String text = "";
for (char ch: s.toCharArray()) {
if (Character.isDigit(ch)) {
result += String.valueOf(ch);
} else {
text += String.valueOf(ch);
int textIdx = Arrays.asList(engArr).indexOf(text);
if (textIdx != -1) {
result += String.valueOf(textIdx);
text = "";
}
}
}
return Integer.parseInt(result);
}
}