Created
October 18, 2018 03:42
-
-
Save manivelarjunan/5dae1cf6b62bc3440c7ec30b4bf97102 to your computer and use it in GitHub Desktop.
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
// 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