dots are marked on a grid, each given as a pair of coordinates [x, y]. Pick four of them that form the corners of an axis-aligned rectangle such that no other marked point lies inside the rectangle or on its sides.
Return the largest area of such a rectangle, or -1 if no suitable rectangle exists.dots=[[0, 0], [0, 2], [4, 0], [4, 2], [0, 5], [4, 5], [2, 3]] → 8
The rectangle with corners (0, 0) and (4, 2) is empty and has area 8. The one from (0, 2) to (4, 5) is bigger, but (2, 3) lies inside it, and the largest one, from (0, 0) to (4, 5), has (0, 2) and (4, 2) on its sides.
dots=[[1, 1], [1, 4], [6, 1], [6, 4], [3, 4]] → -1
The only rectangle is spoiled by (3, 4) on its top side, so the answer is -1.
dots=[[7, 7]] → -1
dots=[[0, 0], [0, 2], [4, 0], [4, 2], [0, 5], [4, 5], [2, 3]]
8
Run checks the first 3 tests in your browser. Submit checks all 52 tests on the server, hidden ones included.