Mehdi
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
def helper( digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
next_=[1]
i=0
digits=digits[::-1]
j=0
cur=0
res=[]
while(i<len(next_) or j<len(digits)):
first = next_[i] if i<len(next_) else 0
i+=1
second = digits[j] if j<len(digits) else 0
j+=1
sum_=first+second+cur
res.append(sum_%10)
cur=sum_/10
if cur:
res.append(1)
return res[::-1]
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- Mehdi May 14, 2019