Please review this algorithm


  • 0
    A
    sum=0;carry=0
    def fun(l1,r1,carry):
        
        while(l1!=None and r1!=None):
            sum=l1.value+r1.value+carry
            print("l1.value->{}".format(l1.value))
            if(sum<10):
                print(sum)
                l1=l1.next; r1=r1.next 
                return fun(l1,r1,0)
            elif(l1.next!=None and r1.next!=None):
                print(sum%10)
                l1=l1.next; r1=r1.next 
                return fun(l1,r1,1)
            else: 
                print(sum)
                return    
               
    

    Please review this algorithm


Log in to reply
 

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