Skip to content

Commit 2d5d934

Browse files
authored
Create Solution.py
1 parent 5cb92a1 commit 2d5d934

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

solution/0066.Plus One/Solution.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def plusOne(self, digits):
3+
"""
4+
:type digits: List[int]
5+
:rtype: List[int]
6+
"""
7+
8+
i = len(digits)-1
9+
digits[i] += 1
10+
11+
while i > 0 and digits[i] > 9 :
12+
digits[i] = 0
13+
i -= 1
14+
digits[i] += 1
15+
16+
if digits[0] > 9:
17+
digits[0] = 0
18+
digits.insert(0, 1)
19+
20+
return digits

0 commit comments

Comments
 (0)