Last active
February 16, 2017 15:15
-
-
Save balazsnemeth/e7e47513899e483b9e7e1a46ef792f8b to your computer and use it in GitHub Desktop.
Codility solution - AbsDistinct - caterpillar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 100% solution for task: https://codility.com/programmers/lessons/15-caterpillar_method/abs_distinct/ | |
// | |
function solution(A) { | |
var nums = {} | |
for (i of A) { | |
nums[Math.abs(i)] = 1; | |
} | |
return Object.keys(nums).length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment