-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNo.66
39 lines (33 loc) · 830 Bytes
/
No.66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class Solution:
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
t = digits.copy()
carry = 1
for i in range(len(t)-1,-1,-1):
t[i] = t[i] +carry
carry = 0
if t[i] == 10:
t[i] %= 10
carry = 1
if carry == 1:
t.insert(0,1)
return t
#超过 38.2%
class Solution:
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
nums = str()
result = []
for i in digits:
nums = nums + str(i)
nums = int(nums)+1
for num in str(nums):
result.append(int(num))
return result
#超过 98.8%