Created
September 11, 2017 23:36
-
-
Save Smakar20/1de4c3d07b44c063459ab128f7c20425 to your computer and use it in GitHub Desktop.
null created by smakar20 - https://repl.it/Kx1O/0
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
function ArrayAdditionI(arr) { | |
// code goes here | |
var sortedArr = arr.sort(function(a, b) { | |
return a - b}), sum = 0, numMap = {} | |
console.log("sortedArr: ", sortedArr) | |
for(var i = 0; i< sortedArr.length-1; i++){ | |
sum += sortedArr[i] | |
numMap[sortedArr[i]] = sortedArr[i] | |
if(sum == sortedArr[sortedArr.length-1] || numMap[sum - sortedArr[sortedArr.length-1]] != undefined) return "true" | |
} | |
return "false" | |
} | |
ArrayAdditionI([4, 6, 23, 10, 1, 3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment