We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cffe172 commit 60654adCopy full SHA for 60654ad
66. Plus One.py
@@ -0,0 +1,28 @@
1
+# -*- coding: utf-8 -*-
2
+# @Time : 2019/2/27 11:18
3
+# @Author : xulzee
4
+# @Email : [email protected]
5
+# @File : 66. Plus One.py
6
+# @Software: PyCharm
7
+from typing import List
8
+
9
10
+class Solution:
11
+ def plusOne(self, digits: List[int]) -> List[int]:
12
+ l = len(digits)
13
+ digits[l - 1] += 1
14
+ j = l - 1
15
+ while digits[j] >= 10:
16
+ if j == 0:
17
+ digits[j] = 0
18
+ digits.insert(0, 1)
19
+ return digits
20
21
+ j -= 1
22
+ digits[j] += 1
23
24
25
26
+if __name__ == '__main__':
27
+ N = [0]
28
+ print(Solution().plusOne(N))
0 commit comments