Skip to content

Commit 65e82f7

Browse files
authored
Update katie.md
1 parent af368df commit 65e82f7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

problems/2181/katie.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@ When we get to another 0, we want to repeat this process.
88
The 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">

0 commit comments

Comments
 (0)