Google Interview Question for Software Engineers


Country: United States
Interview Type: Phone Interview




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

Lets say the paper are lying in front of you in the following order :

X Y 1 2

You know that X,Y have some number written at the back and 1,2 have a letter.

You need to check a minimum of 2 conditions :

1) Check whether paper X has even number written on the back.
2) Check whether the paper marked 1 has Y written on the back.

With these cases, you can conclude that paper with X will have even number on the back.

- nivethavadivelu February 23, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
3
of 3 votes

Why do we need to check, paper marked as 1. rather than that i guess one has to check the paper marked 2 has X written on the back.

- Zzenith February 23, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Zzenith.. I thought the same.

- Murali Mohan February 23, 2015 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 votes

We have to check the 1 to make sure it doesn't have an X on the other side (as that would invalidate all X's having even numbers on the back). We don't have to check the 2, because it's an even number, so we either find an X and it still holds, or we find a Y and we don't learn anything.

- azoerb February 23, 2015 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

The question is ambiguous. "To prove that a paper with the letter x contains an even number on the other side" could mean either to prove that one such paper exists, or to prove that all papers with an 'x' have an even number on the other side.

- tjcbs2 February 26, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Actually I think you can check 2. If it contains Y on the back then 1 MUST contain X.

I think the minimum to prove is 1 because if you check 2 first and you get X then you got lucky and proved X has an even number. Likewise if you had checked X first and it had 2 on the back.

- Alex February 27, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The question is to check if X has even numbers, not even numbers have X. so we should check if All X doesn't contain odd number. So X's and odd numbers, hence 2

- VS May 16, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The question is to check if X has even numbers, not even numbers have X. so we should check if All X doesn't contain odd number. So X's and odd numbers, hence 2

- VS May 16, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I guess two.

Check X and 1.

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

front%2+back%2 == 0

- ajeet February 23, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

further explanation : ascii value of X is even so you don't need to check for X and Y

- ajeet February 23, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think this would work from an algorithmic stand point and from reading nivethavadivelu's logical explanation, can anyone confirm?

- LeetJile February 24, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I thinks, its 3.
check for x.
check for 1,
check for 2.

explanation: suppose user has to return true or false for each paper. he has to check for x, if the front contains 1 or 2.

- Zzenith February 23, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

(front&0x01 + back&0x01) == 0

- ajeet February 23, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think it should be only 1.
check for X only , If it is written 2 then then condition is true . If any other numbe ris written then condition is false.

- shel February 23, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nope, because we need to make sure the 1 does not have an X on the back, otherwise we cannot prove that all papers with X have an even number on the other side.

- azoerb February 23, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

-- Check X if its turn-over is 2
-- Check 2 if its turn-over is X

So total 2 checks

- w.y February 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You need 1 check since you can always reduce the maximum number of 'suspects' to 2 (i.e. either you have 2 X's, 2 Twos, X and Two etc.).
Other papers are irrelevant to your check.

- avico81 February 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

One need to check two conditions :
1) We first need to check whether the opposite of two is X only.
2) Then we need to make sure that on other side of 2 is X only.

We cant reduce it to one check since after either of above one condition we cant be sure of other conditions getting true automatically because that is not provided in the question

- Ishant June 15, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Think about it as if you are getting handed papers with only one side up showing...
You must iterate through all papers with either

1) a X facing up, so make sure 2 is on the other side; OR
2) a 1 facing up, so make sure the X is NOT on the other side

That would be fully sufficient because no other case invalidates the statement:
Ex. 2,Y-Don't care(Because we only care about Xs having 2s) Y-(2/1) Don't Care

- aml081 October 20, 2015 | Flag Reply


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