1459. Rectangles Area
https://leetcode.com/problems/rectangles-area
Description
Table: Points
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| id | int |
| x\_value | int |
| y\_value | int |
+---------------+---------+
id is the primary key for this table.
Each point is represented as a 2D coordinate (x\_value, y\_value).Write an SQL query to report all possible axis-aligned rectangles with non-zero area that can be formed by any two points in the Points table.
Each row in the result should contain three columns (p1, p2, area) where:
p1andp2are theid's of the two points that determine the opposite corners of a rectangle.areais the area of the rectangle and must be non-zero.
Report the query in descending order by area first, then in ascending order by p1's id if there is a tie, then in ascending order by p2's id if there is another tie.
The query result format is in the following table:
ac
Previous1458. Max Dot Product of Two SubsequencesNext1460. Make Two Arrays Equal by Reversing Sub-arrays
Last updated
Was this helpful?