68.52 %
class Solution {
public boolean isRationalEqual(String S, String T) {
return Double.valueOf(normalize(S)).compareTo(
Double.valueOf(normalize(T))) == 0;
}
private String normalize(String s) {
int index = s.indexOf("(");
String result = s;
if (index > 0) {
result = s.substring(0, index);
for (int i = 0; i < 20; i++) {
result += s.substring(index + 1, s.length() - 1);
}
}
return result;
}
}
No comments:
Post a Comment