Skip to content

Commit 933191a

Browse files
authored
Create 137-single-number-ii.js
1 parent 75869bc commit 933191a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

137-single-number-ii.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
const singleNumber = function(nums) {
6+
const hash = {}
7+
8+
nums.forEach(el => {
9+
hash[el] = (hash[el] && hash[el] + 1) || 1
10+
})
11+
12+
for(let el in hash) {
13+
if(hash[el] === 1) return +el
14+
}
15+
};

0 commit comments

Comments
 (0)