← All problemsSign in

8. String to Integer (atoi)

LeetCodeStringOpen on judge ↗

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: Determine the sign by checking if the next character is '-' or '+', assuming positivity if neither present. - Conversion: Read the integer by skipping leading zeros until a non-digit chara

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start