@@ -0,0 +1,2245 @@
+package fundamentals.string.convert.lc065_validnumber;%0A%0A/**%0A */%0Apublic class Solution %7B%0A%0A    public boolean isNumber(String s) %7B%0A        s = s.trim();%0A        boolean num = false, dot = false, e = false, nume = true;%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            char c = s.charAt(i);%0A            if (c == '+' %7C%7C c == '-') %7B         // Only see + and - in the beginning and after an e%0A                if (i != 0 && s.charAt(i - 1) != 'e') return false;%0A            %7D else if (Character.isDigit(c)) %7B  // See %5B0-9%5D and reset the number flags%0A                num = nume = true;%0A            %7D else if (c == '.') %7B              // Only see . if we didn't see e or .%0A                if (dot %7C%7C e) return false;%0A                dot = true;%0A            %7D else if (c == 'e') %7B              // Only see e if we didn't see e but see a number. Reset nume to require num.%0A                if (e %7C%7C !num) return false;%0A                e = true;%0A                nume = false;%0A            %7D else return false;%0A        %7D%0A        return num && nume;%0A    %7D%0A%0A    // Format: +/-    345  .14    e+/-10%0A    //        %5Bsign%5D %5Bnum%5D %5Bfrac%5D %5Bsci%5D%0A    // Note: -.1 or 1., at least one part is not empty%0A    public boolean isNumber1(String s) %7B%0A        char%5B%5D c = s.trim().toCharArray();%0A        int i = 0, n = c.length;%0A%0A        // 1.Optinal +/- sign%0A        if (i %3C n && (c%5Bi%5D == '+' %7C%7C c%5Bi%5D == '-')) i++;%0A%0A        // 2.Optinal integral part%0A        int j = i;%0A        i = readNum(c, i, false);%0A%0A        // 3.Optional fractional part%0A        if (i %3C n && c%5Bi%5D == '.') %7B // if no integral part (j==i), then must have one digit at least%0A            if ((i = readNum(c, i + 1, j == i)) == -1) return false;%0A        %7D%0A%0A        // 4.Optional scientific notation%0A        if (j %3C i && i %3C n && c%5Bi%5D == 'e') %7B // must have leading digit, eg. e10%0A            i++;%0A            if (i %3C n && (c%5Bi%5D == '+' %7C%7C c%5Bi%5D == '-')) i++;%0A            if ((i = readNum(c, i, true)) == -1) return false;%0A        %7D%0A        return j %3C i && i == n; // at least one digit, eg. +, -%0A    %7D%0A%0A    private int readNum(char%5B%5D c, int i, boolean isRequired) %7B%0A        int j = i;%0A        while (i %3C c.length && Character.isDigit(c%5Bi%5D)) i++;%0A        return (isRequired && i == j) ? -1 : i;%0A    %7D%0A%0A%7D%0A

valid number