Interview Question


Country: United States




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

construct the Graph like this:set a edge between the two people who dislike each other.We can consider : if A dislikes B,it means that B dislikes A too.Then the minimum number of the homes is the minimum color number of the graph.

- notbad July 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is correct. Unfortunately coloring is NP-complete. This problem is too, because every coloring problem can be reduced to an instance of this problem.

- eugene.yarovoi July 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

@ eugene.yarovoi ....thats correct ..otherwiz all NP hard prblms will be solvable...

- atul gupta July 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 4 vote

1. Invert the graph.
2. Count the no. of connected sets.

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

Super!... Draw undirected edge between two nodes where one people dislike other..

modify the adjacency matrix in which you have to set 1 where the value is 0 and vice versa

draw the graph again and now, no. of connected graph gives minimum number of home

- cobra July 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This approach is completely invalid. Suppose I have 3 people, and 1 dislikes 3. The inversion of that graph is still 1 connected component. This problem is the same as graph coloring, which is NP-complete.

- eugene.yarovoi July 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Suppose the dislike graph forms two disjoint sets, in this case the inverse graph is always a connected(so every node is taken into a room).

- SantiagoYemmiganur July 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@ eugene.yarovoi ....thats correct ..otherwiz all NP hard prblms will be solvable...

- atul gupta July 17, 2012 | 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