clueless coding // TODO: be smarter

LeetCode Single Number: Java Solution



TL;DR Code Solution


public int singleNumber(int[] nums) {

    int res = 0;
    for (int i = 0; i < nums.length; i++) {
        res ^= nums[i];
    }
    return res;

}