silver-hands / sss

0 stars 0 forks source link

【Q102】136. 只出现一次的数字 #102

Open fly0o0 opened 4 years ago

fly0o0 commented 4 years ago

136. 只出现一次的数字

fly0o0 commented 4 years ago
/**
 * @param {number[]} nums
 * @return {number}
 */
var singleNumber = function(nums) {

  let single = 0
  for (let n of nums) {
    single ^= n
  }

  return single
};