## Google Interview Question for Java Developers

Country: United States

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

fix any arbitary point, find another point that results in the minimum/maximum slope

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

Graham scan algorithm.

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

Graham scan could be used to find convex hull.

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

Create equation of the line by selected two points.
Check every other point by this equation:
if result >0 then point at one side of the line
if result < 0 then point at another side of the line
if result == 0 the point belongs to line.

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

Absolutely right Computational Geometry, Thats Convex Hull. Crazy Question man

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

``````public static Point[] func(Point[] points) {
if (points == null || points.length <= 1) return null;
int length = points.length;
Point firstPoint = points[0];
int j = 0;
for (int i = 1; i < length; i++) {
Point tempPoint = points[i];
if (tempPoint.x < firstPoint.x) {
firstPoint = tempPoint;
j = i;
}
}
for (int i = 0; i < length; i++) {
if (flag) {
}
}
}

private static boolean checkDirection(Point p1, Point p2, Point p3) {
int value = ((p3.y - p2.y)*(p2.x-p1.x)) - ((p2.y - p1.y)*(p3.x-p2.x));
if (value > 0) return true;
return false;
}

static class Point {
int x;
int y;
Point (int xx, int yy) {
x = xx;
y = yy;
}
}``````

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

Only the first step of a graham scan is needed. Scan once for the lowest x co-ordinate and find another point with the largest angle to that point.

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.

### 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.