https://leetcode.com/problems/xor-operation-in-an-array/description/ Easy

Условие

Даны целые n и start. Массив nums длины n формируется по правилу

nums[i] = start + 2 * i

Необходимо вернуть результат побитовой операции XOR всех элементов массива nums.

Решение

class Solution {
    fun xorOperation(n: Int, start: Int): Int {
        var result = 0
		    repeat(n) { i -> result = result xor (start + 2 * i) }
		    return result
    }
}