(99+) Erect the Fence - LeetCode
The idea behind Jarvis Algorithm is really simple. We start with the leftmost point among the given set of points and try to wrap up all the given points considering the boundary points in counterclockwise direction.
This means that for every point considered, we try to find out a point , such that this point is the most counterclockwise relative to than all the other points. For checking this, we make use of orientation()
function in the current implementation. This function takes three arguments , the current point added in the hull; , the next point being considered to be added in the hull; , any other point in the given point space. This function returns a negative value if the point is more counterclockwise to than the point .
Read full article from (99+) Erect the Fence - LeetCode
No comments:
Post a Comment