String to Integer atoi 🔥| Leetcode 8 | String

preview_player
Показать описание
Timestamps:
Problem explanation: 00:00
Approaching the problem: 04:14
Dry Run: 06:53
Code Explanation: 13:15
Complexity Analysis: 16:38

Time Complexity : O(n)
Space Complexity : O(1)


Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)

#DataStructuresAndAlgorithms
#stringToInteger
#interviewpreparation
String to Integer atoi solution
String to Integer atoi Leetcode
String to Integer atoi C++
String to Integer atoi Java
String to Integer atoi Python

🔥🔥🔥🔥👇👇👇

Checkout the series: 🔥🔥🔥
LIKE | SHARE | SUBSCRIBE 🔥🔥😊
Рекомендации по теме
Комментарии
Автор

I am newbie, have two doubts.
1) why we using long to define ans
2)in the line ans=ans*10+s[i]-' 0 ' what is purpose of this one'0'

I hope you will explain it😢😢

selvarajan
Автор

I saw multiple video solutions but no one able to clear this much. Good job. Keep doing good work. Thanks!!

susmitapatil
Автор

Videos are helpful. Just adding the python version in case anyone needs
class Solution:
def myAtoi(self, str: str) -> int:
# for removing white spaces
str = str.strip()
if not str:
return 0
sign = -1 if str[0] == '-' else 1
str = str[1:] if str[0] in ['-', '+'] else str
res = 0
for char in str:
if not char.isdigit():
break
res = res * 10 + int(char)
if res * sign >= 2**31 - 1:
return 2**31 - 1
if res * sign <= -2**31:
return -2**31
return res * sign

OatsAurCode
Автор

You don't know how happy i am after seeing your video in search result...every time.

tusharnain
Автор

really great explanation !!!! found this after watching some tuff explaining videos....keep doing well....

eehg
Автор

Clear explanation, every second was worth it!!

hemantsharma
Автор

Detailed explanation for each case...!!Wow

hrithikrudra
Автор

I love your voice❤️, such a nice explanation keep uploading quality content.

raviashwin
Автор

Crystal clear Explanation. Thanks! Happy Makar Sankranti ! 😇

ChandraShekhar-bycd
Автор

Awesome explanation thanks for providing java solution as well means a lot you're an inspiration

SubhasisNandaYoganeer
Автор

Explanation is best. Just wanted to know is cp mandatory for coding rounds of product based companies. If yes then how to begin.

OatsAurCode
Автор

thankyou so much for such an easy explanation of this problem <3!!

ishangujarathi
Автор

Best explanation among all videos of this prob I have ever You

amarjeetkumarsingh
Автор

Very nice, crisp and intutive approach didi thanks a lot

sayanraha
Автор

thanks Maam for the crystal and clear explanation 👏👏

MAYANKSINGH-mfll
Автор

Thanks Ayushi for this awesome explanation❤❤

allmovies
Автор

i think in second while loop, it should be s[i]==' ' instead of s[0]==' ' .

chiragjain
Автор

*line 24 & 25* should include equal to also, like this

if( sign==-1 && -1*ans <= INT_MIN ) return INT_MIN;
if( sign==1 && INT_MAX <= ans ) return INT_MAX;

anshumaan
Автор

Thanks a lot for this awesome explanation.

vineetkumar
Автор

🎯 Key points for quick navigation:

00:02 *Handle leading whitespace*
00:42 *Convert string to integer*
01:25 *Check sign (positive/negative)*
02:08 *Read until non-digit*

Made with HARPA AI

ankithshetty