摘要:
import java.util.regex.Pattern;public class Solution { Pattern p = Pattern.compile("^[\\+\\-]?((\\d+(\\.\\d*)?)|(\\.\\d+))(e[\\+\\-]?\\d+)?$"); public boolean isNumber(String s) { String ss = s.trim(); return p.matcher(ss).matches(); }}偷懒,用了正则表达式。不过也试了9次才过。难怪通过率那么低。Pattern p 的... 阅读全文