gary@interview:~/interview/coding/369-plus-one-lin….md$
$ cat ./coding/369-plus-one-linked-list.md
[Coding]

369. Plus One Linked List

────────────────────────────────────────────────────────────

369. Plus One Linked List

# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def plusOne(self, head: ListNode) -> ListNode:
        tmp = ListNode()
        tmp.next = head
        not_nine = tmp

        while head:
            if head.val != 9:
                not_nine = head
            head = head.next

        not_nine.val += 1
        not_nine = not_nine.next

        while not_nine:
            not_nine.val = 0
            not_nine = not_nine.next

        return tmp if tmp.val else tmp.next

--tags#Classic
$ ls ./coding/ | grep -v 369-plus-one-linked-list
265. Paint House II256. Paint House143. Reorder List1762. Buildings With an Ocean View
← cd ../codingcd ~