🌐
LeetCode
leetcode.com › problems › string-to-integer-atoi
8. String to Integer (atoi)
8. String to Integer (atoi) Medium · Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer. The algorithm for myAtoi(string s) is as follows: Whitespace: Ignore any leading whitespace (" "). Signedness: ...
🌐
AlgoMonster
algo.monster › home › 8. string to integer (atoi)
8. String to Integer (atoi) - In-Depth Explanation
The problem asks you to implement a function myAtoi(string s) that converts a string to a 32-bit signed integer, similar to C/C++'s atoi function.
Discussions

After 3 hours of pain and misery, my solution to “String to Integer” on LeetCode
Your approach to taking screenshots is deeply disturbing. More on reddit.com
🌐 r/programminghorror
169
2245
January 4, 2024
atoi the function used to convert a string to an integer...but...
I don't understand what you're asking at all. This function can only be used on a string that can be parsed as a series of decimal digits (optionally with a sign), not any arbitrary string. If you try to convert a string that's not in that format, then it fails and returns zero. That's also why this function is deprecated and should not be used, because you can't tell the difference between a successful conversion of the string representation of zero and the failure case of an invalid string. More on reddit.com
🌐 r/C_Programming
20
1
July 17, 2016
Atoi.
The atoi function is for converting a string (that is, char*) to an int. A char is not a string. The good news is that char is already a numeric type. You can just write int num = argv[1][k]; print("success: %d\n", num); Even if you do need to convert a string to an int, you shouldn't use atoi, because it lacks error handling. You can pass in "flurbl" and it will still return an int value. Instead you should use strtol or sscanf. In the former case you need to set errno=0 first, in order to distinguish overflow from a correct conversion of INT_MAX or INT_MIN. More on reddit.com
🌐 r/C_Programming
8
0
April 17, 2019
Atoi
atoi converts a string to a number. It will not work with individual characters, only with a null-terminated string. You seem to be trying to convert individual characters of argv[1] to integers, rather than trying to convert argv[1] itself. Note that you should only try to convert argv[1] after you have checked all characters of argv[1] to make sure that they are valid digits. More on reddit.com
🌐 r/cs50
11
4
April 17, 2019
🌐
WalkCCC
walkccc.me › LeetCode › problems › 8
8. String to Integer (atoi) - LeetCode Solutions
LeetCode Solutions in C++23, Java, Python, MySQL, and TypeScript.
🌐
DEV Community
dev.to › grantdotdev › leetcode-8-string-to-integer-atoi-medium-33om
LeetCode 8: String to Integer (atoi) - Medium - DEV Community
September 21, 2025 - LeetCode's String to Integer (atoi) is a classic medium-difficulty coding problem that challenges you to convert a string representation of a number into an actual integer.
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › write-your-own-atoi
String to Integer - Write your own atoi() - GeeksforGeeks
Write your own atoi() that takes a string (which represents a floating point value) as an argument and returns its value as double.
Published: April 14, 2026
🌐
Medium
medium.com › @rutujakbhombe19 › solving-leetcode-until-i-land-a-job-306a30914738
Leetcode 8 : String to Integer (atoi) | by Rutuja Bhombe | Medium
July 17, 2024 - Read each character until a non-digit character is encountered or the end of the string is reached. Convert these characters into a number. ... If the number is outside the range of a 32-bit signed integer, clamp it to the range limits.
🌐
PROGIEZ
progiez.com › 8-string-to-integer-atoi-leetcode-solution
8. String To Integer (atoi) LeetCode Solution - Progiez
September 12, 2024 - class Solution { public int myAtoi(String s) { s = s.strip(); if (s.isEmpty()) return 0; final int sign = s.charAt(0) == '-' ? -1 : 1; if (s.charAt(0) == '+' || s.charAt(0) == '-') s = s.substring(1); long num = 0; for (final char c : s.toCharArray()) { if (!Character.isDigit(c)) break; num = num * 10 + (c - '0'); if (sign * num <= Integer.MIN_VALUE) return Integer.MIN_VALUE; if (sign * num >= Integer.MAX_VALUE) return Integer.MAX_VALUE; } return sign * (int) num; } } // code provided by PROGIEZ
🌐
Red Quark
redquark.org › leetcode › 0008-string-to-integer-atoi
LeetCode #8 - String To Integer (atoi) | Red Quark
Input: str = "-91283472332" Output: -2147483648 Explanation: The number "-91283472332" is out of the range of a 32-bit signed integer. Therefore INT_MIN (−2^31) is returned. From the problem statement and examples, it is clear that we only want to convert those strings which starts either ...
Find elsewhere
🌐
Gitbook
zhenchaogan.gitbook.io › leetcode-solution › leetcode-8-string-to-integer-atoi
LeetCode 8. String to Integer (atoi) | leetcode solution
Read in next the characters until the next non-digit charcter or the end of the input is reached. The rest of the string is ignored. Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32).
🌐
GitHub
github.com › doocs › leetcode › blob › main › solution › 0000-0099 › 0008.String to Integer (atoi) › README_EN.md
leetcode/solution/0000-0099/0008.String to Integer (atoi)/README_EN.md at main · doocs/leetcode · GitHub
Conversion: Read the integer by skipping leading zeros until a non-digit character is encountered or the end of the string is reached. If no digits were read, then the result is 0. Rounding: If the integer is out of the 32-bit signed integer ...
Author: doocs
🌐
LeetCode
leetcode.ca › all › 8.html
8. String to Integer (atoi) - leetcode.ca
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.
🌐
Medium
medium.com › @soham-khade › 8-string-to-integer-atoi-leetcode-problem-java-042a26831f49
8. String to Integer (atoi) LeetCode Problem (Java) | by Soham | Medium
October 27, 2023 - Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored. Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32).
🌐
Gitbooks
frankchen0521.gitbooks.io › leetcode-swift › content › 8string-to-integer-atoi.html
8.String to Integer (atoi) · LeetCode - Swift - Frank Chen
If no valid conversion could be performed, a zero value is returned. If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned. ... class Solution { func myAtoi(_ str: String) -> Int { let sign:[Character] = ["+", "-"]; let ...
🌐
Techlarry
techlarry.github.io › Leetcode › 8. String to Integer (atoi)
8. String to Integer (atoi)
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.
🌐
YouTube
youtube.com › watch
String To Integer (atoi) - 8. LeetCode - Java - YouTube
String To Integer (atoi) - 8. LeetCode - Java Github repo: https://github.com/teddysmithdev/LeetCodeJava2024LeetCode description: https://leetcode.com/proble...
Published: August 20, 2024
🌐
YouTube
youtube.com › watch
STRING TO INTEGER (ATOI) | PYTHON | LEETCODE # 8 - YouTube
In this video we are solving a popular interview question at top tech companies Google, Facebook, Microsoft, and others. This is a pretty simple question but...
Published: March 2, 2022
🌐
Reddit
reddit.com › r/leetcode › solved leetcode 8 (string to integer – atoi) | thoughts on edge cases & overflow handling
r/leetcode on Reddit: Solved LeetCode 8 (String to Integer – atoi) | Thoughts on edge cases & overflow handling
January 6, 2026 - I just finished LeetCode #8 (String to Integer – atoi) and found it to be a nice test of careful string parsing rather than pure logic. The tricky…
🌐
Paul Coroneos
pcoroneos.com › blog › atoi
Solving Leetcode 8 - String to Integer (atoi) (JavaScript) - Paul Coroneos
July 29, 2020 - The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.
🌐
Medium
abdullahniaz.medium.com › leetcode-problem-8-string-to-integer-atoi-2af6971d9cc9
LeetCode Problem: 8. String to Integer (atoi) | by Abdullah Niaz | Medium
January 23, 2025 - Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer.