Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sum two linked lists if numbers are reversed in linked list

    def sum_two_lists(self, llist):
        cur = self.head
        cur1 = llist.head
        n1 = 0
        n2 = 0
        remainder = 1
        while cur:
            n1 += (cur.data) * remainder
            remainder *= 10
            cur = cur.next
        remainder = 1
        while cur1:
            n2 += (cur1.data) * remainder
            remainder *= 10
            cur1 = cur1.next
        total = str(n1 + n2)[::-1]
        answer = LinkedList()
        for i in total:
            answer.append(i)
        return answer
Comment

PREVIOUS NEXT
Code Example
Python :: if lower: --- 71 doc = doc.lower() 72 if accent_function is not None: 73 doc = accent_function(doc) 
Python :: python list of deeper paths 
Python :: icloud api python 
Python :: python aus liste tuple machen 
Python :: quadrilateral 
Python :: copy something character ubntil a specific character in python 
Python :: python string: string concatenation 
Python :: reverse sublist of linklist 
Python :: how to hack instagram account using python 
Python :: wrds in python 
Python :: convert only time to unix timestamp python 
Python :: airflow set ui color of operator ui_color 
Python :: how to test webhook in python.py 
Python :: calc investiment money puthon 
Python :: python quickly goto line in file 
Python :: tz convert python 
Python :: indexers in python 
Python :: print poo 
Python :: gdal warp and glob through directory 
Python :: "not equal to" python symbol 
Python :: RuntimeError: DataLoader worker (pid(s) 13615) exited unexpectedly 
Python :: <function chr(i, /)> error in python 
Python :: factorielle python 
Python :: Image loader RGB transform 
Python :: python: if null give a value if not null concatenate 
Python :: how to get a mouse press not hold in pygame 
Python :: exec inside def is not working in python 
Python :: compile and train cnn models 
Python :: DRf Representation 
Python :: copy any files from one folder to another folder in python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =