Skip to content

Instantly share code, notes, and snippets.

@iAnisdev
Last active February 13, 2023 10:40
Show Gist options
  • Save iAnisdev/2b4f0a456c6db179409ba4fa6f2911cc to your computer and use it in GitHub Desktop.
Save iAnisdev/2b4f0a456c6db179409ba4fa6f2911cc to your computer and use it in GitHub Desktop.
Find set of sum in a number
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