recursion2
recursion2
def __init__(self,value):
self.value = value
self.next = None
class Solution:
dummy = ListNode()
res = dummy
total = carry = 0
while l1 or l2 or carry:
total = carry
if l1:
total += l1.val
l1 = l1.next
if l2:
total += l2.val
l2 = l2.next
num = total % 10
carry = total // 10
dummy.next = ListNode(num)
dummy = dummy.next
return res.next
class Solution:
answer = 0
while head:
head = head.next
return answer
class Solution:
if n <= 1:
return n
class Solution:
if n <= 1:
return n
a, b = 0, 1
a, b = b, a + b
return b
class Solution:
if n <= 0:
return False
while n % 3 == 0:
n //= 3
return n == 1
class Solution:
if n <= 0:
return False
if n == 1:
return True