Skip to content

Wanwan87 2. add two numbers 1#5

Open
wanwan87 wants to merge 4 commits into
mainfrom
wanwan87-2.-Add-Two-Numbers-1
Open

Wanwan87 2. add two numbers 1#5
wanwan87 wants to merge 4 commits into
mainfrom
wanwan87-2.-Add-Two-Numbers-1

Conversation

@wanwan87
Copy link
Copy Markdown
Owner

@wanwan87 wanwan87 commented May 7, 2026

Comment thread 2. Add Two Numbers.md
Comment on lines +138 to +145
if l1 is not None:
value1 = l1.val
else:
value1 = 0
if l2 is not None:
value2 = l2.val
else:
value2 = 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

個人的にはこっちの方が2行で済んで読みやすいかと思いました。

value1 = l1.val if l1 is not None else 0
value2 = l2.val if l2 is not None else 0

Comment thread 2. Add Two Numbers.md
Comment on lines +151 to +154
if l1 is not None:
l1 = l1.next
if l2 is not None:
l2 = l2.next
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ここに関しても同様です。

l1 = l1.next if l1 else None
l2 = l2.next if l2 else None

Comment thread 2. Add Two Numbers.md
value2 = l2.val
else:
value2 = 0
tmp = value1 + value2 + carry
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ここの変数名は例えばdigit_sumとするとtmpよりもわかりやすいと思います。

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.

ありがとうございます、tmpは何が入っているか分かりにくいですね

Comment thread 2. Add Two Numbers.md
add_result = ListNode()
carry = 0
while l1 is not None and l2 is not None:
tmp = l1.val+l2.val
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+ の両側にスペースが空けるのと空いていないのが統一されていない点が気になりました。空けるほうに統一するとよいと思います。

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants