```
class Solution:
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
digits[-1] += 1
digits.insert(0, 0) # add a leading zero
for i in range(len(digits) - 1, 0, -1):
if digits[i] == 10:
digits[i] = 0
digits[i - 1] += 1
if digits[0] == 0:
return digits[1:]
else:
return digits
```