Skip to content

Latest commit

 

History

History
20 lines (18 loc) · 348 Bytes

README.md

File metadata and controls

20 lines (18 loc) · 348 Bytes

Single Number

Solution 1

/**
 * Question   : 136. Single Number
 * Complexity : Time: O(n) ; Space: O(1)
 * Topics     : Bit
 */
class Solution {
    public int singleNumber(int[] nums) {
        int res = nums[0];
        for (int i = 1; i < nums.length; i++) {
            res ^= nums[i];
        }
        return res;
    }
}