Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by danjurious ( 8 years ago )
class Solution {
public int myAtoi(String str) {
int result = 0;
int sign = 1;
if (str == null) {
return result;
} else {
str = str.trim();
}
if (str.length() == 0) {
return result;
}
for (int i = 0; i < str xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed>= '0' && c <= '9';
}
private boolean isSafeToMultiply(int left, int right) {
if (0 == left) {
return true;
}
return (Integer.MAX_VALUE / left) >= right;
}
private boolean isSafeToAdd(int left, int right) {
return (Integer.MAX_VALUE - left) >= right;
}
}
Revise this Paste