camelCase
BAN USER1. Have a method angleFromOrigin(int x, int y) or (Point p) that returns the angle from whatever axis you choose. (if you pass in 3, 4 it will return 30 degrees or whatever). This will allow you to order them from their angle from a given axis.
2. Iterate through the points and put the result in a List<PointWithAngle>
PointWithAngle {
Point p;
int angleFromAxis;
}
3. Sort the list based on angleFromAxis.
4. Find the largest subset that has a difference less than the alpha angle.
This can be done by having a two index system that runs along the array and increments when the points are outside the alpha angle.
5. Return the last point in the subset's angle (if your reference axis is the beta angle's axis).
Hope that makes sense,
Initializing list by running through points: O(n)
Sorting list: O(nlogn)
Finding the largest subset: O(n)
Runtime: O(nlogn)
The denominator should be 2*level not level^2, what happens when there's 7 liters and you want glass 8?
- camelCase July 18, 2013