Skip to content

Instantly share code, notes, and snippets.

@MohammedALREAI
Created March 5, 2021 14:10
Show Gist options
  • Select an option

  • Save MohammedALREAI/9051549c09c993f45251d6f9e9f64845 to your computer and use it in GitHub Desktop.

Select an option

Save MohammedALREAI/9051549c09c993f45251d6f9e9f64845 to your computer and use it in GitHub Desktop.
136. Single Number leetcode
function singleNumber(nums: number[]) {
let set= new Set<number>();
for(let i of nums){
if(set.has(i)){
set.delete(i);
}else{
set.add(i);
}
}
for(let i of set){
return i;
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment