Skip to content

Conversation

@SuperHotDogCat
Copy link
Owner

if head.next and head.val == head.next.val:
head = skip_duplicated_nodes(head)
else:
current_node.next = ListNode(head.val)

Choose a reason for hiding this comment

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

ListNode()で新たにオブジェクトを作らなくてもheadの繋ぎかえでいけると思います。

head = head.next
return head
dummy_head = ListNode(-1)
current_node = dummy_head

Choose a reason for hiding this comment

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

個人的にはcurrent_nodeは今注目しているもの(今回であれば重複判定とかするポインタ)の名前にする方が分かりやすいかなと思いました。
本コードではheadが使われてますね。

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