Google Interview Question for Software Engineers


Country: United States




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

{{
Could you clarify more on the problem. What kind of graph is this? What does it mean to subdivide graph equally by 2 points? Some sample.
}}

- EPavlova November 22, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{{
Could you clarify more on the problem. What kind of graph is this? What does it mean to subdivide graph equally by 2 points? Some sample.
}}

- ep November 22, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Dynamic Programming.

1) First do DFS to count the number of points (only if it's unknown)
2) Then starting from the end nodes (which only have one connected node), maintain a count at every node which indicates all the nodes connected in the graph up till that point, including the node itself. When this number reached n/2 (where n is the number of nodes), that node and any outgoing connecting node (which has not already been considered) represent the two nodes which can subdivide the graph.

Also, since n is even, n/2 is an integer, meaning that when searching, you need to search for when the count reaches exactly n/2.

- Ahmad November 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How would you find the end nodes given vertices and edges?

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

You traverse the graph using DFS or BFS.

- Ahmad November 27, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you give an example?

It is confusing how two nodes can subdivide a graph. Even if you cut the edge between two nodes the graph can still be connected.

- lepeisi November 28, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Sort the points. The two points of interest are n/2 and ceil(n+1/2). Essentially the median points.

- CPPC November 21, 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