Google Interview Question for Developer Program Engineers






Comment hidden because of low score. Click to expand.
2
of 2 vote

What the hell are those guys thinking about merge sort?
Just use scan the string, O(n)

- idiot February 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Can you please elaborate on what do you mean by "out of order"?

- elaborate January 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If out of order means any change in increasing or decreasing order of ASCII values of individual characters in the string, then its straight forward by comparing the first two characters and identifying the order is increasing or decreasing and accordingly proceed from third location till they go out of order.

It its something like Special characters comes in one group, number comes in one and similarly A-Z in one and a-z in another group and when a sequence of characters from one group is disturbed by occurrence of a character from another group defines the out of order, then we need change our logic in terms of checking for range of ASCII values for each group.

But I am not sure if my understanding of out of order is right. Please post ur comments.

- UB_Green January 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

String contains only letters either upper case or lower case
ABCDAFGH the we should return 4
ABCDaF then we should return 4

if we encounter any letter other than a-z or A-Z the method should return ERROR

- jp January 08, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

if we are using first two elements to find the order, care must be taken when the first two elements are same.

- Anonymous January 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

if we are using first two elements to find the order, care must be taken when the first two elements are same.

- Anonymous January 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

if we are using first two elements to find the order, care must be taken when the first two elements are same.

- Anonymous January 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Ask the definition of "OUT OF ORDER"
Below are the examples of OUT OF ORDER

1. ABCDEFP.... (Difference 1)
2. ACEGIKR.... (Difference 2)
3. AEIOUAEIOP ... (Vowel &Consonents)
4. ABECIDOFL ... (Vowel & Consonets sequence)

etc...

- Anonymous January 13, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

how is the difference in the 2nd case is 2? please explain..!!

- scofield January 18, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class test {

public static void main(String[] args) {
String a = "nopsdv";


int prev = (int)a.charAt(0);
int curr = (int)a.charAt(0);
for(int i=0; i<a.length();i++) {
curr = (int)a.charAt(i);

if(curr<prev) {
System.out.println("char:"+a.charAt(i)+" index:"+i);
break;
}
else
prev = curr;
}
}
}

- aj January 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public int findIndexOutOrder(String str) {
String lowStr = str.toLowerCase();
char pre =' ';
if(lowStr.length()>0) {
pre =lowStr.charAt(0);
if(pre<'a' || pre>'z')
return -1;
}
for(int i=1;i<lowStr.length();i++) {
char cur = lowStr.charAt(i);
if(cur<'a' || cur>'z')
return -1;
if(cur<pre)
return i;
pre = cur;
}
return -1;
}

- ben.hakunamatata January 31, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

in the above code checking should be for && and not ||

- Anonymous February 05, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def method(String inputString):
order = "none"
inputStringList = list(inputString)
if int( inputStringList[0] ) <= int( inputStringList[1] ):
order = "increasing"
elif:
order = decreasing
for preIndex,pre in enumerate( inputStringList[:len(inputStringList)-1] ):
nextIndex = preIndex + 1
if order =="increasing":
if inputStringList[preIndex] > inputStringList[nextIndex]:
flag = false
elif order == "decreasing":
if inputStringList[preIndex] <= inputStringList[nextIndex]:
flag = false
if flag = False:
return False
elif:
return True

- weijiang2009 February 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey64343" class="run-this"> public int inorderCheck(char [] c){

int sum0=0,sum1=0;
if(c.length==0) return -1;
for(int i=0;i<c.length;i++){

sum1=0;
if(i==0)continue;
sum0=Character.toUpperCase(c[i-1])-'A';
char ch= Character.toUpperCase(c[i]);
sum1= ch-'A';
if(sum1<sum0)return i;


}
return -1; // the string is in order



}
</pre><pre title="CodeMonkey64343" input="yes">
char []characters1 = new char[]{'D','O','P','a','Z'};
char []characters2 = new char[]{};
char []characters3 = new char[]{'D','O','P','q','Z'};
char []characters4 = new char[]{'p','D','O','P','a','Z'};
System.out.println( new InOrderCheck().inorderCheck(characters1));
System.out.println( new InOrderCheck().inorderCheck(characters2));
System.out.println( new InOrderCheck().inorderCheck(characters3));
System.out.println( new InOrderCheck().inorderCheck(characters4));</pre>

- Anonymous August 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

apply merge sort technique and count out of order, similar to find number of inversions.

- Anonymous January 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Apply trie tree nd u will get the answer..
Merge Sort lagayenge..
hahaha..

- Anonymous January 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

aur aap Trie kaise lagayenge yeh to bataye hi nahi!!

- interviewer February 06, 2011 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

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.

Learn More

Resume Review

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.

Learn More

Mock Interviews

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.

Learn More