Python solution using reversed list


  • 0
    S
        num = 0
        r_num = []
        for i in xrange(len(digits)):
            num = 10*num
            num = num + digits[i]
            
        num = num+1
        
        for i in xrange(len(digits)):
            temp_num = num%10
            num = num/10
            r_num.append(temp_num)
        r_num.reverse()
        if r_num[0] == 0:
            r_num.insert(0, 1)
        return r_num

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.