DEV Community

ZeeshanAli-0704
ZeeshanAli-0704

Posted on

Single Number Check

var singleNumber = function(nums) {

   const hash = {};

  for (const el of nums) {
    if (!hash[el]) {
      hash[el] = 1;
    } else {
      delete hash[el]
    }
  }

  return Object.keys(hash)[0];
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)