**For example: 8->7->9->9**

Add dummy: 0->8->7->9->9

The lastNotNine is 7.

7 + 1 = 8

9 change to 0.

We got 0->8->8->0->0

return dummy.next

**For example: 9->9->9**

Add dummy: 0->9->9->9

The lastNotNine is 0.

0 + 1 = 1

9 change to 0.

We got 1->0->0->0

return dummy

```
public class Solution {
public ListNode plusOne(ListNode head) {
ListNode dummy = new ListNode(0);
dummy.next = head;
ListNode lastNotNine = dummy;
ListNode node = head;
while(node != null){
if(node.val != 9){
lastNotNine = node;
}
node = node.next;
}
lastNotNine.val = lastNotNine.val + 1;
lastNotNine = lastNotNine.next;
while(lastNotNine != null){
lastNotNine.val = 0;
lastNotNine = lastNotNine.next;
}
return dummy.val == 1 ? dummy : dummy.next;
}
}
```