Quoestion:Click here
Python Code:
class Solution(object):
def plusOne(self, digits):
for i in range(len(digits)-1,-1,-1):
if digits[i]==9:
digits[i]=0
else:
digits[i]=digits[i]+ 1
return digits
newarr=[0]*(len(digits)+1)
newarr[0]=1
return newarr
class Solution(object):
def plusOne(self, digits):
for i in range(len(digits)-1,-1,-1):
if digits[i]==9:
digits[i]=0
else:
digits[i]=digits[i]+ 1
return digits
newarr=[0]*(len(digits)+1)
newarr[0]=1
return newarr
Copyright (c) 2020 codetoskill.com All Right Reseved
0 Comments