class Solution:
def addOne(self, head):
def reverseList(head):
front, mid, back = head, None, None
while front:
front, mid, back = front.next, front, mid
mid.next = back
return mid
new_head = reverseList(head)
carry = 1
curr, prev = new_head, None
while curr:
carry, curr.data = divmod(curr.data + carry, 10)
curr, prev = curr.next, curr
if carry:
prev.next = Node(carry)
return reverseList(new_head)