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