String to Integer (atoi)
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.
Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible to gather all the input requirements up front.
In Java, the integer ranges from -2,147,483,648 to +2,147,483,647
A) Read the string from left to right and convert each character to its ASCII value
B) Convert the string to a long integer first to handle overflow
C) Use regular expressions to extract the integer part of the string
D) Handle leading whitespace and check for overflow/underflow