Three Number Sum

Given a integer array and magic number, if there are any three numbers in the array sum up to magic number return true, else return false. Input: Array: {-10, -9, -7, 5, 0, 99} Arraylength: 6 MagicNumber: -17 Output: true Input: Array: {0, 1, 3, 5, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0} Arraylength: 14 MagicNumber: 21 Output: false public class Answer implements ThreeNumberSumInterface { @Override public boolean ThreeNumberSum(final int [] arr, int arrlen, int magicNumber) { // WRITE YOUR CODE HERE return true; } public static void main(String [] args) { // write code here to test } }

Answer

No comments:

Post a Comment