bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 587. Erect the Fence

587. Erect the Fence

Leetcode Solutions

Approach: Jarvis Algorithm

  1. Find the leftmost point in the set of points.
  2. Initialize the current point as the leftmost point found.
  3. Loop until the hull is formed: a. Select the next point by finding the most counterclockwise point relative to the current point. b. Check for collinear points and include the farthest one. c. Update the current point to the next point.
  4. Repeat the process until the starting point is reached again.
  5. Return the points that form the convex hull.
UML Thumbnail

Approach: Graham Scan Algorithm

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...