Ruaconlonton123
Senior Member
Tuần này nhẹ nhàng
Python:
class Solution:
def mergeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:
fast = head.next
slow = ListNode(0)
while fast:
if fast.val != 0:
slow.val += fast.val
elif fast.val == 0 and fast.next:
slow = slow.next
slow.val = 0
else:
slow.next = None
fast = fast.next
return head


