Facebook Interview Question for Software Engineer / Developers






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

Would someone please delete this Facebook puzzle as:
1. It is not a real interview question.
2. It clutters the list of questions.
3. Solution requires several steps and it is pointless to publish it in its entirety.

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

Dijsktra, using as weight the following function

w(A,B) = (time to got from A to B) * (probability of B)

- Claudio October 12, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Dan, what ever it is, but it got some strategy to solve
I recommend two data structures, one is to maintain a array of pointers to lists,each pointer is pointing to list of reachable locns from locn, in non decreasing order of their probabilities

-----
addr1| ->locn3(0.4,4 sec)->locn4(0.1,45 sec)->null
-----
addr2|->null
-----
addr3|->locn2(0.2,34 sec)->locn1(0.2, 76 sec)->null
-----

other is a map<locn,bool> set to all false on start, which on reaching is set to true

typdef struct
{
prob;
duration;
locn;
List* next;
}List;

typdef struct
{
locn;
bt * next;
}bt;
Bt *bt;

int locate(vector<List*> list ,map<locn> m)
{
int i=0;
double total_duration;
List temp = list[i];
bool found = false;
int total_locn = m.size();//total entries
int total_visited =1;
do
{
if( total_locn == total_visited)
{
print(total_duration);
return 0;
}

while(temp || m(temp)) temp=temp->next;
if(!temp) // no more movements
{
print("NO SoLUTION");
return 1;
}
else
{
m(temp) = true;
total_duration += temp->duration;
add_traversal_path(bt,temp->locn);
temp = set_vector_index(temp);// sets temp with list pointer of current locn
total_visited++;
add_traversal_path(bt,temp);// for tracking path

}
}(while(!found))
return 0;
}

- Master Fuji June 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Well, I agree with Dan. This type of puzzle is not good suit to be posted here. Thousands of puzzle are on Wu Riddle forum. Or, you could better post on stackoverflow. I'm not saying there is no point to solve a puzzle, but as Dan pointed few reasons already.

On the other hand, it could be possible to narrate the original problem concisely. That way, more people would be encouraged to get the problem, and try to solve it.

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

Not a puzzle at all. A graph w/ double weighting: both time & probability. Any help/hint from a graph expert please?

- ZhY July 25, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I have the whole solution to this puzzle, simply because I solved it before. It is ranked at the hardest level of facebook puzzles, though much easier than another one: FACEBULL based on my experience, as well as many others'. This problem is non-trivial, there is no polynomial solution (for sure) to it. All we can do is how to search efficiently. I used a lot of heuristic methods and pruning methods to exponentially speedup my search. Though it passes test cases in several milliseconds, but it is still possible (I guess) to make a counter-example that make all my pruning and heuristic fail and result in a very long running time. I tried to make such one to refine my algorithm, but it turned out it is even more difficult than FINDSOPHIE itself to design such a special counter-example...

- fentoyal January 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

completely agree with fentoyal, this is an NPC problem.
prove:
1. Hamiltonian path is NPC
2. because of 1, the problem "given an undirected graph G, given a specific vertex v in G, whether there exists a Hamiltonian path starting from v in G" is NPC
3. because of 2, given an undirected graph G, given a specific vertex v in G, if we are going to try to find whether there exists a Hamiltonian path starting from v in G, we will surely expect an NPC algorithm. Good. Let's do it this way: define all vertex of possibility 1/V, where V is the # of vertices in G; define all edges of length 1, now we ask: is there such a route s.t. we visit all vertices and the expected traveling distance is exactly ???, where ??? is the traveling distance assuming no vertex is visited twice. If we can solve this in linear time, then the problem in 2 is not NPC. Thus, this problem is NPC.
4, because of 3, same assumption as 3, if we can solve the problem, "finding the minimal" in linear time, we can surely answer the "whether a special ???? length route exists" because we simply compare ???? with the "minimal". Thus this problem is NPC.
If I were to answer this question, as much as I hate it, I would use a naive brute-force scan of all permutations of the position, and then visit them in that order to all permutations, and select the minimal.
If the interviewer is not happy about that, I'll tell him, if two solutions are both exponential, they are equally disappointingly slow to me and thus make no difference and you can go **** yourself.
Well...I might have gone too far...

- Tracy February 16, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

how about using A* search ?

- dan.dimerman April 22, 2013 | 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