IOS|IOS 算法(基础篇) ----- 数组异或操作

给你两个整数,n 和 start 。
数组 nums 定义为:nums[i] = start + 2*i(下标从 0 开始)且 n == nums.length 。
请返回 nums 中所有元素按位异或(XOR)后得到的结果
输入:n = 5, start = 0
输出:8
解释:数组 nums 为 [0, 2, 4, 6, 8],其中 (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8 。
"^" 为按位异或 XOR 运算符
输入:n = 4, start = 3
输出:8
解释:数组 nums 为 [3, 5, 7, 9],其中 (3 ^ 5 ^ 7 ^ 9) = 8.
遍历法 按照题意机械翻译即可
未翻译版
func xorOperation(_ n: Int, _ start: Int) -> Int {var result = start for i in 1..

翻译版
func xorOperation(_ n: Int, _ start: Int) -> Int {// 定义result, 初始值为start var result = start// 循环异或操作 for i in 1..

【IOS|IOS 算法(基础篇) ----- 数组异或操作】题目来源:力扣(LeetCode) 感谢力扣爸爸 :)
IOS 算法合集地址

    推荐阅读