posts, where posts[i] = [x, y]. No two posts share a spot.
A farmer wants to fence a rectangular paddock whose sides run parallel to the axes and whose four corners are all posts from the list. Other posts may end up inside the paddock or on its sides; that is fine.
Return the smallest possible area of such a paddock. If no rectangle can be formed, return 0.posts=[[0, 0], [0, 2], [5, 0], [5, 2], [3, 0], [3, 2], [1, 1]] → 4
Rectangles 3 × 2, 2 × 2 and 5 × 2 are possible. The smallest lies between x = 3 and x = 5, with area 4.
posts=[[1, 1], [2, 2], [3, 1], [2, 4]] → 0
No four posts form a rectangle with sides along the axes, so the answer is 0.
posts=[[2, 7], [6, 7], [2, 10], [6, 10]] → 12
The four posts are the corners of a single 4 × 3 rectangle, area 12.
posts.length ≤ 500posts[i].length = 2x, y ≤ 4 · 10⁴posts=[[0, 0], [0, 2], [5, 0], [5, 2], [3, 0], [3, 2], [1, 1]]
4
Run checks the first 3 tests in your browser. Submit checks all 83 tests on the server, hidden ones included.