ICPC REGIONAL CONTEST ASU CHALLENGE (2024–2025)
2 min readOct 15, 2024
Chill, it’s easy Problems!
class Solution(object):
def canWinNim(self, n):
"""
:type n: int
:rtype: bool
"""
return n % 4 != 0
class Solution(object):
def isTriangle(self, sides):
if len(sides) != 3:
return False
sides.sort()
if sum(sides[:2]) > sides[2]:
return True
return False
def largestPerimeter(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
n = len(nums)
nums.sort(reverse=True)
for i in range(n - 2):
if self.isTriangle([nums[i], nums[i+1], nums[i+2]]):
return nums[i] + nums[i+1] + nums[i+2]
return 0
3. Distribute Money to Maximum Children
class Solution(object):
def distMoney(self, money, children):
"""
:type money: int
:type children: int
:rtype: int
"""
if not money / children >= 1:
return -1
if money < 8:
return 0
if money / 8 == children:
return children
receivers = [1] * children
money -= children
for i in range(children):
if money >= 7 and not (children - 1) == i:
receivers[i] += 7
money -= 7
elif money == 3:
receivers[i] += 2
if (children - 1) == i:
receivers[i-1] += 1
money -= 3
else:
money -= 2
else:
receivers[i] += money
break
return receivers.count(8)
Added some problems with chili peppers!
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def addTwoNumbers(self, l1, l2):
d = ListNode()
h = d
q = 0
while l1 or l2 or q:
val_1 = l1.val if l1 else 0
val_2 = l2.val if l2 else 0
total = val_1 + val_2 + q
q = total // 10
total = total % 10
h.next = ListNode(total)
h = h.next
if l1: l1 = l1.next
if l2: l2 = l2.next
return d.next