Asunto: https://leetcode-cn.com/problems/string-to-integer-atoi/
Respuesta: cadena
public int myAtoi (String str) {
str = str.trim ();
int len = str.length ();
if (len == 0) return 0;
char [] chars = str.toCharArray ();
booleano negativo = falso;
int índice = 0;
if (chars [index] == '-') {
negativo = verdadero;
índice ++;
} else if (chars [index] == '+') {
índice ++;
} else if (! Character.isDigit (chars [index])) {
return 0;
}
int años = 0;
while (index <len && Character.isDigit (chars [index])) {
int dígito = caracteres [índice] - '0';
if (ans> (Integer.MAX_VALUE - digit) / 10) {
devolver negativo? Integer.MIN_VALUE: Integer.MAX_VALUE;
}
años = años * 10 + dígito;
índice ++;
}
devolver negativo? -ans: ans;
}