237、删除链表中的节点
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteNode(self, node):
"""
:type node: ListNode
:rtype: void Do not return anything, modify node in-place instead.
"""
node.val = node.next.val
node.next = node.next.next
238、除自身以外数组的乘积
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
products = [1]
for i in range(1,len(nums)):
products.append(nums[i-1]*products[-1])
right_product = 1
for i in range(len(nums)-1,-1,-1):
products[i] *= right_product
right_product *= nums[i]
return products
292、Nim游戏
class Solution:
def canWinNim(self, n: int) -> bool:
m=n
m=str(m)
m=m[-2:]
m=int(m)
return (m!=0)and(m!=4)and(m!=8)and(m!=12)and(m!=16)and(m!=20)and(m!=24)and(m!=28)and(m!=32)and(m!=36)and(m!=40)and(m!=44)and(m!=48)and(m!=52)and(m!=56)and(m!=60)and(m!=64)and(m!=68)and(m!=72)and(m!=76)and(m!=80)and(m!=84)and(m!=88)and(m!=92)and(m!=96)