String to Integer (atoi)

Medium
StringParsingMathAmazonMicrosoft
Parse a string as a 32-bit signed integer. Input format: - One line: s Ignore leading spaces, read an optional sign, then read consecutive digits. Stop at the first non-digit after parsing starts. Clamp values below -2147483648 or above 2147483647.

Constraints

0 <= s.length <= 2 * 10^5

Sample tests

Sample 1

Sample 2

Sign in to submit