Skip to content

8. String to Integer (atoi)#60

Open
kitano-kazuki wants to merge 1 commit into
mainfrom
8-string-to-integer
Open

8. String to Integer (atoi)#60
kitano-kazuki wants to merge 1 commit into
mainfrom
8-string-to-integer

Conversation

@kitano-kazuki
Copy link
Copy Markdown
Owner

Comment thread memo.md
is_leading_zeroes = False
num = 0
while i < len(s) and s[i].isdecimal():
if is_leading_zeroes:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_leading_zeroesがデフォルトfalseなのでこちらの分岐には入らない気がします
leading zeroの扱いについては特に考慮しなくて良いので結果的に正しく動いてるということでしょうか

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは動かないですね。きっと。。。。
leetcode上にコピペして, leetcodeのエディタで行った修正をこっちに反映し忘れたのだとおもいます

Comment thread memo.md

is_leading_zeroes = False
num = 0
while i < len(s) and s[i].isdecimal():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isdecimalは「Unicode の decimal digit 全般」を表すため今回はUnicodeポイントを直接比較する方が良いと思います。'0' <= c <= '9'

https://docs.python.org/3/library/stdtypes.html#str.isdecimal

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

知らなかったです。ありがとうございます

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants