3625. Count Number of Trapezoids II Hard
1/**
2 * [3625] Count Number of Trapezoids II
3 *
4 * <p data-end="189" data-start="146">You are given a 2D integer array points where points[i] = [xi, yi] represents the coordinates of the i^th point on the Cartesian plane.
5 * <p data-end="189" data-start="146">Return <em data-end="330" data-start="297">the number of unique trapezoids that can be formed by choosing any four distinct points from points.
6 * <p data-end="579" data-start="405">A trapezoid is a convex quadrilateral with <strong data-end="496" data-start="475">at least one pair of parallel sides. Two lines are parallel if and only if they have the same slope.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">points = [[-3,2],[3,0],[2,3],[3,2],[2,-3]]</span>
11 * Output: <span class="example-io">2</span>
12 * Explanation:
13 * <img alt="" src="https://assets.leetcode.com/uploads/2025/04/29/desmos-graph-4.png" style="width: 250px; height: 250px;" /> <img alt="" src="https://assets.leetcode.com/uploads/2025/04/29/desmos-graph-3.png" style="width: 250px; height: 250px;" />
14 * There are two distinct ways to pick four points that form a trapezoid:
15 *
16 * The points [-3,2], [2,3], [3,2], [2,-3] form one trapezoid.
17 * The points [2,3], [3,2], [3,0], [2,-3] form another trapezoid.
18 * </div>
19 * <strong class="example">Example 2:
20 * <div class="example-block">
21 * Input: <span class="example-io">points = [[0,0],[1,0],[0,1],[2,1]]</span>
22 * Output: <span class="example-io">1</span>
23 * Explanation:
24 * <img alt="" src="https://assets.leetcode.com/uploads/2025/04/29/desmos-graph-5.png" style="width: 250px; height: 250px;" />
25 * There is only one trapezoid which can be formed.
26 * </div>
27 *
28 * Constraints:
29 *
30 * 4 <= points.length <= 500
31 * –1000 <= xi, yi <= 1000
32 * All points are pairwise distinct.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/count-number-of-trapezoids-ii/
38// discuss: https://leetcode.com/problems/count-number-of-trapezoids-ii/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn count_trapezoids(points: Vec<Vec<i32>>) -> i32 {
44 0
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3625() {
56 }
57}
58Back
© 2026 bowen.ge All Rights Reserved.