Skip to content

Instantly share code, notes, and snippets.

@famousgarkin
Created August 23, 2016 13:57
Show Gist options
  • Save famousgarkin/4274ded50d05844c9c459db0524ec72f to your computer and use it in GitHub Desktop.
Save famousgarkin/4274ded50d05844c9c459db0524ec72f to your computer and use it in GitHub Desktop.
Codility - Lesson 3: Time Complexity - PermMissingElem (https://codility.com/programmers/task/perm_missing_elem/)
function solution(A) {
A.push(0)
return A.reduce(function(missing, value, i) {
return missing + i + 1 - value
}, 0)
}
var A = []
A[0] = 2
A[1] = 3
A[2] = 1
A[3] = 5
var test = solution(A)
console.log(test, test === 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment