Skip to content

Instantly share code, notes, and snippets.

@sharmaabhinav
Last active December 9, 2017 18:26
Show Gist options
  • Save sharmaabhinav/7d040a4236d527f7f1dde566281acb56 to your computer and use it in GitHub Desktop.
Save sharmaabhinav/7d040a4236d527f7f1dde566281acb56 to your computer and use it in GitHub Desktop.
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