Google Interview Question for Software Engineer / Developers






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

Draw a directed graph and bicolor it.members of same color hv same attitude

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

Can you please explain your solution with small example.. :)

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

here's the explanation of the example given in the question

A-->B means A accuses B
here we go

Step--->Tom--->Gal|
 ^      ^^--------|
 |      |
Geo---->Iss

now take 2 colors eg)red,green
color any node as green eg)Step as Green
color the graph such that no neighbor of 'x' has same color as 'x'...so Tom is red,Gal is green,Geo is red,Iss is green...totally 3 greens and 2 reds
U should always be able to bicolor the graph cos the question says "everyone seems to be either unfailingly honest or compulsively deceptive"

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

Same algorithm that I came up with :)

- KV July 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is it really a question taken on phone/onsite google interview? It looks like some programming contest (UVA, topcoder etc) question? Or, some written exam?

Would u mind to give reference to this question? Thanks.

- anonymous June 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

it's from FACEBOOK puzzles

- arpit June 28, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Draw a directed graph and bicolor it.members of same color hv same attitude

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

Draw a directed graph and bicolor it.members of same color hv same attitude

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

Draw a directed graph and bicolor it.members of same color hv same attitude

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

Draw a directed graph and bicolor it.members of same color hv same attitude

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

What can be the best data structure to code this algorithm in java ?

- govind June 30, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

public static String getLiarLiar()
    {
	
	HashSet<String> setOne = new HashSet<String>();
	HashSet<String> setTwo = new HashSet<String>();
	
	try
	{
	    Scanner scan = new Scanner(new FileInputStream("liarliar.txt"));
	    
	    int number = scan.nextInt();

	    for (int i =0; i<number;i++)
	    {
		boolean snitchInSetOne = false;
		boolean snitchInSetTwo = false;

		String name = scan.next();
		int tellNum = scan.nextInt();
		
		HashSet<String> tellSet = new HashSet<String>(1);
		tellSet.add(name);
		
		if (setOne.contains(name)) // if teller is in setOne
		{
		    snitchInSetTwo = true;
		}
		else if (setTwo.contains(name)) // if teller is in setTwo
		{
		    snitchInSetOne = true;
		}
		
		HashSet<String> snitchSet = new HashSet<String>(tellNum);

		for(int j=0;j<tellNum;j++)
		{
		    String snitch = scan.next();
		    snitchSet.add(snitch);
		    
		    if (setOne.contains(snitch))
		    {
			snitchInSetOne = true;
		    }
		    else if (setTwo.contains(snitch))
		    {
			snitchInSetTwo = true;
		    }
		}
		
		if (snitchInSetOne)
		{
		    setOne.addAll(snitchSet);
		    setTwo.addAll(tellSet);
		}
		else if (snitchInSetTwo)
		{
		    setOne.addAll(tellSet);
		    setTwo.addAll(snitchSet);
		}
		else	// if it's all empty
		{
		    setOne.addAll(tellSet);
		    setTwo.addAll(snitchSet);
		}
		
	    }
	}
	catch (FileNotFoundException e)
	{
	    e.printStackTrace();
	}
	
	return (setOne.size()>setTwo.size()) ? setOne.size()+" "+ setTwo.size():setTwo.size() +" "+setOne.size();
    }

- Anonymous April 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The code is wrong, For example
A->B
C->D
A->C
Your code can't handle this situation..

- tianyang19910112 March 05, 2014 | 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