Professional Documents
Culture Documents
Pair With Sum
Pair With Sum
Pair With Sum
*/
//are they all integers? Yes
// whether they are all sorted list? Yes
// Do I need to provide the pair or just a yes/true or no/false? Just a boolean
// Approach#1: Iterate "elements" in nested loops, so for each try to add next
element to see if the sum is 8.
// if we total sum is 8, then return true. else keep looking for others.
import java.util.Set;
import java.util.HashSet;
public class PairWithSum{
//Improve Complexity;
// Null Checks & Error Handling.
//Approach#2:
//nlog(n)
//1+x = 8 => x=8-1