---
# System prepended metadata

title: 0369. Plus One Linked List
tags: [Leetcode, Linked List, Medium]

---

# 0369. Plus One Linked List
###### tags: `Leetcode` `Medium` `Linked List`
Link: https://leetcode.com/problems/plus-one-linked-list/
## 思路
recursion找到下一位的carry 加到当前node上即可
## Code
```java=
class Solution {
    public ListNode plusOne(ListNode head) {
        ListNode dummyNode = new ListNode(0);
        dummyNode.next = head;
        compute(dummyNode);
        if(dummyNode.val==0) return head;
        else return dummyNode;
    }
    private int compute(ListNode curr){
        int val;
        if(curr.next==null){
            val = curr.val+1;
            
        }
        else{
            int carry = compute(curr.next);
            val = curr.val+carry;
        }
        curr.val = val%10;
        return val/10;
    }
}
```