I tried to solve using your code but was failing at some edge cases, so I tried to debug and now it works fine def myAtoi(self, s: str) -> int: s = s.lstrip() if not s: return 0 if len(s)==1 and not s[0].isdigit(): return 0 i = 0 sign = 1 if s[i]=="+": i+=1 if s[i]=="-": sign = -1 i+=1 if i==2: return 0 parsed = 0 while i2**31-1: return 2**31-1 elif parsed
@crackfaang2 жыл бұрын
Not sure how that’s possible unless Leetcode changed the test cases or you made a mistake when copying over my code. Glad you got it working though
@ritwik_shivam2 жыл бұрын
@@crackfaang Yeah I might have made some mistake, and thanks for the code once again it was clear and understandable, your "glad you got it working" gave a lot of motivation to code and debug on my own for upcoming questions, subscribed your channel😃😃
@ashutoshrautela34542 жыл бұрын
Keep growing 👍🏻
@crackfaang2 жыл бұрын
Make sure to subscribe and let me know if there's any videos you'd like me to make in the future :)
@rakeshramesh92482 жыл бұрын
i dont think in the interview you can use int(), rather use ASCII values to get the int out of it