is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
If I give input as 7,6,3,4,5,5,2,8,5,5 the output will be
- prajyod February 01, 2016Pair:7,3
Pair:6,4
Pair:5,5
Pair:2,8
Number of Combinations:4
public class SumOfCombinations {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String[] numbers = in.nextLine().split(",");
int sum = in.nextInt();
int combinations = 0;
Map<Integer,Integer> mappings = new HashMap<>();
Set<Integer> unique = new HashSet<>();
for(int i=0;i<numbers.length;i++){
int key = Integer.parseInt(numbers[i]);
if(mappings.containsKey(key) && !unique.contains(key)){
int value = mappings.get(key);
if(value == sum-key){
++combinations;
unique.add(key);
System.out.println("Pair:"+value+","+key);
}
}else if(!mappings.containsKey(key)){
mappings.put(sum-key, key);
}
}
System.out.println("Number of Combinations:"+combinations);
}
}