删除链表中的节点
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
除自身以外数组的乘积
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
res=[1]
p=1
q=1
for i in range(len(nums)-1):
p*=nums[i]
res.append(p)
for i in range(len(nums)-1, 0, -1):
q*=nums[i]
res[i-1]*=q
return res
Nim游戏
class Solution:
def canWinNim(self, n: int) -> bool:
return bool(n%4!=0)