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.
public class ArraynNumber {
- rohit.emmadishetty February 23, 2017public void subsetsCheckSum(int[] arr, int num) {
int n = arr.length;
int sum;
List<Integer> listel = new ArrayList<Integer>();
if (arr.length >= 1) {
// Run a loop for printing all 2^n
// subsets one by one
for (int i = 0; i < (1 << n); i++) {
listel.clear();
sum = 0;
// Print current subset
for (int j = 0; j < n; j++) {
// (1<<j) is a number with jth bit 1
// so when we 'and' them with the
// subset number we get which numbers
// are present in the subset and which
// are not
if ((i & (1 << j)) > 0)
listel.add(arr[j]);
}
for (int k = 0; k < listel.size(); k++) {
sum = sum + listel.get(k);
}
if (num == sum) {
System.out.println(listel.toString());
Collections.reverse(listel);
System.out.println(listel.toString());
}
}
}
}
public static void main(String[] args) {
int number;
ArraynNumber anr = new ArraynNumber();
List<Integer> list = new ArrayList<Integer>();
Scanner scr = new Scanner(System.in);
try {
number = Integer.parseInt(scr.nextLine());
while (list.isEmpty()) {
String str = scr.nextLine();
String[] strArray;
strArray = str.split(" ");
for (int i = 0; i < strArray.length; i++) {
list.add(Integer.parseInt(strArray[i]));
}
}
int[] myArray = new int[list.size()];
for (int j = 0; j < list.size(); j++) {
myArray[j] = list.get(j);
}
anr.subsetsCheckSum(myArray, number);
} catch (Exception e) {
e.printStackTrace();
} finally {
scr.close();
}
}
}