Fork me on GitHub

算法养成计划--day5

20220911

昨天中秋节休息一天
第二题直接看答案,很巧妙的方法,充分的利用异或的性质来写循环。mark一下

第一题

nums[::2], nums[1::2] = nums[:n], nums[n:]

第二题

nums = [5,1,6]
candidates = [0]
for x in nums:
    candidates += [x^y for y in candidates] 
sum(candidates)
posted @ 2022-09-11 20:24  Mo槑  阅读(3)  评论(0编辑  收藏  举报