Last active
December 9, 2017 18:26
-
-
Save sharmaabhinav/7d040a4236d527f7f1dde566281acb56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function countOfNumbers (arr) { | |
var divisor = arr.length + 1 | |
var returnArr = [] | |
for(var i=0;i<arr.length;i++) { | |
arr[arr[i] % divisor - 1] += divisor | |
} | |
for(var i=0;i<arr.length;i++) { | |
returnArr.push([i+1, Math.floor(arr[i] / divisor) ]) | |
} | |
return returnArr | |
} | |
console.log(countOfNumbers([5,5,5,5,5])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment