Java 1 ms solution


  • 1
    P

    public class Solution {

        public int singleNumber(int[] nums) {
        if (nums == null) {
            return -1;
        }
        int result = 0;
        for (int n : nums) {
            result = result ^ n;
        }
        return result;
    }
    


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.