class Solution(object):
def xorOperation(self, n, start):
"""
:type n: int
:type start: int
:rtype: int
"""
sum = start
nums = []
for i in range(n):
nums.append(start+2*i)
for j in range(1, n):
sum = sum ^ nums[j]
return sum
1486. 数组异或操作(LeetCode-力扣-Python)
最新推荐文章于 2024-11-10 13:43:20 发布