EngTW / English-for-Programmers

《程式英文》:用英文提昇程式可讀性
971 stars 45 forks source link

1486. XOR Operation in an Array #84

Closed twy30 closed 3 years ago

twy30 commented 3 years ago

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

public class Solution
{
    public int XorOperation(int n, int start)
    {
        // 「運算步驟的數量」
        var operationCount = n;

        // 「起始數值」
        var startValue = start;

        // 「輸出值」
        var output = startValue;

        for (int i = 1; i < operationCount; ++i)
        {
            output ^= startValue + 2 * i;
        }

        return output;
    }
}

請參考「刷 LeetCode 練習命名」 https://github.com/EngTW/English-for-Programmers/issues/69 😊