#3625
Count Number of Trapezoids II
hard · 40.1% accepted · 259 likes · top 19%
array · hash table · math · geometry
Description
You are given a 2D integer array points where points[i] = [xi, yi] represents the coordinates of the ith point on the Cartesian plane.
Return the number of unique trapezoids that can be formed by choosing any four distinct points from points.
A trapezoid is a convex quadrilateral with at least one pair of parallel sides. Two lines are parallel if and only if they have the same slope.
Solution