Google Interview Report
- 0of 0 votes
Answerint[] first = {3}; // size 1
- Madan January 28, 2014 in United States
int[] second = new int[3]; // size 3
second[0] = 2;
second[1] = 4; //2,4
Second array has enough space to hold all elements of first and second array, where both the arrays are merged. Now write code to have first array into second.
The following Cracking the coding interview code doesn't work.
public static int[] merge2(int[] first, int[] second){
int lastA = first.length-1; //0
int lastB = second.length-1; //2
int indexMerge = (lastA + lastB);
while(lastA >= 0 && lastB >= 0){
if(first[lastA] > second[lastB]){
second[indexMerge] = first[lastA];
indexMerge--;
lastA--;
}else{
second[indexMerge] = second[lastB];
indexMerge--;
lastB--;
}
}
while(lastA >= 0){
second[indexMerge] = first[lastA];
indexMerge--;
lastA--;
}
return second;
}| Report Duplicate | Flag | PURGE
Google SDE1 - 0of 0 votes
AnswersImplement a simple regex parser which, given a string and a pattern, returns a boolean indicating whether the input matches the pattern. By simple, we mean that the regex can only contain special character: * (star), . (dot), + (plus). The star means what you'd expect, that there will be zero or more of previous character in that place in the pattern. The dot means any character for that position. The plus means one or more of previous character in that place in the pattern.
- Madan January 28, 2014 in United States| Report Duplicate | Flag | PURGE
Google SDE1 - 0of 0 votes
AnswersStore a set of sudden-death tournament results in a compact format (eg. a bit array) and a set of predicted match results (also in a bit array). Score the predictions, giving one point per correctly guessed match, without unpacking the bit array into a more convenient format (ie. you have to traverse the tree in-place).
- Madan January 28, 2014 in United States| Report Duplicate | Flag | PURGE
Google SDE1 - 0of 0 votes
Answers1. find all the combinations of a string in lowercase and uppercase. For example, string "ab" -> "ab", "Ab", "aB", "AB". So, you will have 2^n (n = number of chars in the string) output strings. The goal is for you to test each of these string and see if it match a hidden string.
- Madan January 28, 2014 in United States| Report Duplicate | Flag | PURGE
Google SDE1