Re: [閒聊] 每日leetcode

作者: DJYOMIYAHINA (通通打死)   2024-07-04 08:11:39
好久沒有遇到linked list了
有過就好
對ㄚ==
一二三四五
def mergeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:
def help(head, cur_sum):
if head is None:
return None
elif head.val == 0:
n = ListNode(cur_sum)
n.next = help(head.next, 0)
return n
else:
return help(head.next, cur_sum+head.val)
return help(head,0).next
作者: sustainer123 (caster)   2024-07-04 08:18:00
大師
作者: rainkaras (rainkaras)   2024-07-04 08:37:00
大師

Links booklink

Contact Us: admin [ a t ] ucptt.com