A delivery-zone map draws the tightest convex outline around all store markers. points holds the distinct marker positions [x, y].
Write zoneCorners(points) that returns the corners of that outline: the convex hull. Points that lie in the middle of a straight edge of the outline are not corners and must be left out. The corners may be returned in any order.
If all points lie on one line, return the two end points. If there is one point, return it alone.
Input: points = [[0,0],[4,0],[4,4],[0,4],[2,2],[2,1]] Output: [[0,0],[4,0],[4,4],[0,4]]
The four corners of the square form the outline. [2, 2] and [2, 1] are inside.
Input: points = [[0,0],[2,1],[4,2],[6,3]] Output: [[0,0],[6,3]]
All points are on one line, so only the two ends are corners.
1 <= points.length <= 10^4-10^4 <= x, y <= 10^4Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #665 Fence Around Map Markers. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.