Skip to content

Commit

Permalink
Time: 988 ms (33.35%), Space: 75.1 MB (22.45%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakeer-official committed Jul 10, 2024
1 parent 79c5921 commit af39089
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:
temp=0
result=ListNode()
mainresult=result
while head:
if head.val==0:
result.next=ListNode(temp)
result=result.next
temp=0
else:
temp=temp+head.val
head=head.next
return mainresult.next.next

0 comments on commit af39089

Please sign in to comment.