Skip to content

Commit 0965f5c

Browse files
committed
完成了66
1 parent 2068192 commit 0965f5c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

66.加一.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# @lc app=leetcode.cn id=66 lang=python3
3+
#
4+
# [66] 加一
5+
#
6+
7+
# @lc code=start
8+
class Solution:
9+
def plusOne(self, digits: List[int]) -> List[int]:
10+
sum = 0
11+
for index in range(len(digits)):
12+
sum = sum+digits[len(digits)-1-index]*(10**index)
13+
sum = sum+1
14+
result = []
15+
for i in str(sum):
16+
result.append(int(i))
17+
return result
18+
19+
# @lc code=end
20+
21+
#ideal
22+
def plusOne(digits):
23+
num = 0
24+
for i in range(len(digits)):
25+
num += digits[i] * pow(10, (len(digits)-1-i))
26+
return [int(i) for i in str(num+1)]
27+
28+

0 commit comments

Comments
 (0)