Google Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

weighted quick-union algorithm is best to find if 2 nodes are connected. with weighted I hope it is also a good option to find the shortest path.
You always connect the smaller tree to the larger tree keeping the height of the tree no more than lg of n.

- Anonymous February 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 votes

Can this be done with Difkstra or BFS or something?

- Guy February 10, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

using quick select you can take the median of the x coordinates and the y coordinates.
the target function is sum i from friend 1 to friend n |friend i x corrdinate -X| + | friend i y coordinate - Y|
we need to find X,Y that minimize it.
and obviosly we get this from the median element from x coordinate list and y coordinate list.

- Anonymous February 25, 2014 | 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