好久沒有遇到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