Tuesday, February 16, 2021

Leetcode. 1486. XOR Operation in an Array. Easy

public class Solution {
    public int XorOperation(int n, int start) {
        int xored = 0;
        for (var i = 0; i < n; ++i) {
            xored ^= start + 2 * i;
        }
        return xored;
    }
}

No comments:

Post a Comment