Removing old questions

Removed questions uploaded using an old version of LeetHub
Questions 2,3,4,19,36,141,206
This commit is contained in:
devenperez
2023-01-08 09:19:00 -05:00
parent 7b2728ea47
commit 4cc7c8cc70
20 changed files with 0 additions and 498 deletions
-38
View File
@@ -1,38 +0,0 @@
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
sum = ListNode((l1.val + l2.val) % 10)
carry = (l1.val + l2.val) / 10
follow = sum
num1 = l1.next
num2 = l2.next
while num1 != None or num2 != None or carry > 0:
if num1 == None and num2 == None:
follow.next = ListNode(carry)
carry = 0
elif num1 == None:
follow.next = ListNode((num2.val + carry) % 10)
follow = follow.next
carry = (num2.val + carry) / 10
num2 = num2.next
elif num2 == None:
follow.next = ListNode((num1.val + carry) % 10)
follow = follow.next
carry = (num1.val + carry) / 10
num1 = num1.next
else:
follow.next = ListNode((num1.val + num2.val + carry) % 10)
follow = follow.next
carry = (num1.val + num2.val + carry) / 10
num1 = num1.next
num2 = num2.next
return sum