Last active
February 13, 2023 10:40
-
-
Save iAnisdev/2b4f0a456c6db179409ba4fa6f2911cc to your computer and use it in GitHub Desktop.
Find set of sum in a number
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 findSums(arr , num){ | |
let result = [] | |
arr.forEach((n , i) => { | |
if(arr.includes(num - n , i)){ | |
result.push([n , num - n]) | |
} | |
}) | |
return result | |
} | |
console.log(findSums([2, 1, 4,5,6,7,0,9,3,2 , 8] , 11)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment