# 【LeetCode with Python】 66. Plus One

## 题目

Given a non-negative number represented as an array of digits, plus one to the number.

The digits are stored such that the most significant digit is at the head of the list.

## 代码

class Solution:
# @param digits, a list of integer digits
# @return a list of integer digits
def plusOne(self, digits):
len_s = len(digits)
carry = 1
for i in range(len_s - 1, -1, -1):
total = digits[i] + carry
digit = int(total % 10)
carry = int(total / 10)
digits[i] = digit
if 1 == carry:
digits.insert(0, 1)
return digits