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.
{
- sreenurao77 June 15, 2016//if n is less than 3 ,then its a trivial palindrome
private static String [] trivialPalin ={"1","11"};
//main method which prints the palindromes
public static void printBinaryPalin(int n){
String arr[]=new String[n];
for(int i=0;i<((n>2)?2:n);i++)
arr[i]=trivialPalin[i];
int digitCount=1;
//for n>2 ,we use a recursive sub method to fetch substrings which are palindromes
//involving zeroes and ones
for(int i=3;i<=n;){
//call submethod which returns substrings of digit count
//for i=3 we call the sub method to return substring of digitcount i-2 ,that is 1 and
//soon
List<String> subStr = fetchSubStrPalin(digitCount);
digitCount++;
for(String str:subStr){
//we append 1 at the beginning to increase digits and a correspoding 1 at
//the end to make it a palindrome
arr[i-1]="1"+str+"1";
i++;
if(i>n)
break;
}
}
//print the accumulated binary palindromes
for(String str:arr){
System.out.println(str);
}
}
//recursive method to return palindromes involving 0 and 1
public static List<String> fetchSubStrPalin(int digits){
List<String> subStrList = new ArrayList<String>();
//trivial case 1
if(digits==1){
subStrList.add("0");
subStrList.add("1");
return subStrList;
}
else if(digits==2){//trivial case 2
subStrList.add("00");
subStrList.add("11");
return subStrList;
}
//if it is not a trivial case call recursively for digits -2
List<String> recursiveRes= (fetchSubStrPalin(digits-2));
//append 0 at beginning and end to make it a palindrome starting and ending with 0
for(String str:recursiveRes){
subStrList.add("0"+str+"0");
}
//similarly append 1 at beginning and end to make it a palindrome with
//begiining and trailing 1's
for(String str:recursiveRes){
subStrList.add("1"+str+"1");
}
return subStrList;
}
}