File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,19 @@ When we get to another 0, we want to repeat this process.
88The final 0 is annoying... I'll add a statement where if the next.next is None, then break out of the loop
99
1010## Attempted solution(s)
11- ``` node = head
11+ ```
12+ # Definition for singly-linked list.
13+ # class ListNode(object):
14+ # def __init__(self, val=0, next=None):
15+ # self.val = val
16+ # self.next = next
17+ class Solution(object):
18+ def mergeNodes(self, head):
19+ """
20+ :type head: Optional[ListNode]
21+ :rtype: Optional[ListNode]
22+ """
23+ node = head
1224 while node.next != None:
1325 if node.next.val != 0:
1426 node.val += node.next.val
@@ -20,3 +32,4 @@ The final 0 is annoying... I'll add a statement where if the next.next is None,
2032 node = node.next
2133 return head
2234```
35+ <img width =" 609 " alt =" Screen Shot 2024-07-04 at 4 18 32 PM " src =" https://github.com/KatieONell/leetcode-solutions/assets/12962290/68480f6c-a1ee-4745-888b-dcbc7ac9ceab " >
You can’t perform that action at this time.
0 commit comments