Skip to content

Instantly share code, notes, and snippets.

@manivelarjunan
Created October 18, 2018 03:42
Show Gist options
  • Save manivelarjunan/5dae1cf6b62bc3440c7ec30b4bf97102 to your computer and use it in GitHub Desktop.
Save manivelarjunan/5dae1cf6b62bc3440c7ec30b4bf97102 to your computer and use it in GitHub Desktop.
// Input [10, 15, 3, 7], Target : 17
// if yes then return true else false.
// Brute force way.
//Solution 1:
function sumOfTwoNum(arr,target){
for(let i = 0 ; i < arr.length; i ++){
for(let j = 0; j < arr.length; j++){
if(i !== j && (arr[i] + arr[j]) === target){
return true;
}
}
}
return false;
};
console.log(sumOfTwoNum([10,15,3,7],18));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment