JavaScript solution


  • 0
    S
    /**
     * @param {number[]} nums
     * @return {number}
     */
    var singleNumber = function(nums) {
        var map = {};
        for (var i = 0, len = nums.length; i < len; i++) {
            var key = nums[i];
            if (!map[key]) {
                map[key] = true;
            }
            else {
                delete map[key];
            }
        }
        for (var i in map) {
            return +i;
        }
    };

Log in to reply
 

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