@@ -0,0 +1,1849 @@
+package me.wayne.leetcodetop100;%0A%0A/**%0A * %E8%AF%B7%E4%BD%A0%E6%9D%A5%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA myAtoi(string s) %E5%87%BD%E6%95%B0%EF%BC%8C%E4%BD%BF%E5%85%B6%E8%83%BD%E5%B0%86%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%E6%8D%A2%E6%88%90%E4%B8%80%E4%B8%AA 32 %E4%BD%8D%E6%9C%89%E7%AC%A6%E5%8F%B7%E6%95%B4%E6%95%B0%EF%BC%88%E7%B1%BB%E4%BC%BC C/C++ %E4%B8%AD%E7%9A%84 atoi %E5%87%BD%E6%95%B0%EF%BC%89%E3%80%82%0A * %3Cp%3E%0A * https://leetcode-cn.com/problems/string-to-integer-atoi/%0A */%0Apublic class LC8_MyAtoi %7B%0A%0A    public int myAtoi(String s) %7B%0A        int i = 0, len = s.length();%0A        //skip space before string%0A        while (i %3C len) %7B%0A            if (s.charAt(i) == ' ') %7B%0A                i++;%0A            %7D else %7B%0A                break;%0A            %7D%0A        %7D%0A%0A        int result = 0;%0A        boolean negative = false;%0A        int digit;%0A        int multmin;%0A        int limit = -Integer.MAX_VALUE;%0A        if (i %3C len) %7B%0A            char firstChar = s.charAt(i);%0A            // Possible leading %22+%22 or %22-%22%0A            if (firstChar %3C '0') %7B%0A                if (firstChar == '-') %7B%0A                    negative = true;%0A                    limit = Integer.MIN_VALUE;%0A                %7D else if (firstChar != '+') %7B%0A                    return 0;%0A                %7D%0A                i++;%0A                if (len == i) %7B%0A                    return 0;%0A                %7D%0A            %7D%0A%0A            multmin = limit / 10;%0A            while (i %3C len) %7B%0A                // Accumulating negatively avoids surprises near MAX_VALUE%0A                digit = Character.digit(s.charAt(i++), 10);%0A                if (digit %3C 0) %7B%0A                    return negative ? result : -result;%0A                %7D%0A                if (result %3C multmin) %7B%0A                    return negative ? Integer.MIN_VALUE : Integer.MAX_VALUE;%0A                %7D%0A                result *= 10;%0A                if (result %3C limit + digit) %7B%0A                    return negative ? Integer.MIN_VALUE : Integer.MAX_VALUE;%0A                %7D%0A                result -= digit;%0A            %7D%0A        %7D else %7B%0A            return 0;%0A        %7D%0A%0A        return negative ? result : -result;%0A    %7D%0A%7D%0A

add LC8_MyAtoi