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.
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
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
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
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
12:13
LeetCode: 8. String to Integer - atoi (Visualized) - YouTube
06:22
String to Integer (atoi) LeetCode 8 | Easy & Clear Explanation ...
String to Integer atoi 🔥| Leetcode 8 | String
16:59
String to Integer atoi 🔥| Leetcode 8 | String - YouTube
- YouTube
WalkCCC
walkccc.me › LeetCode › problems › 8
8. String to Integer (atoi) - LeetCode Solutions
LeetCode Solutions in C++23, Java, Python, MySQL, and TypeScript.
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
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 ...
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.
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
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.