```
class Solution(object):
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
n = len(digits)
if n == 0:
return [1]
for i in xrange(n):
digits[-i-1] += 1
if digits[-i-1] == 10:
digits[-i-1] = 0
else:
break
if i == n-1:
digits.insert(0, 1)
return digits
```