3025. Find the Number of Ways to Place People I Medium

@problem@discussion
#Array#Math#Geometry#Sorting#Enumeration



1/**
2 * [3025] Find the Number of Ways to Place People I
3 *
4 * You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].
5 * Count the number of pairs of points (A, B), where
6 * 
7 * 	A is on the upper left side of B, and
8 * 	there are no other points in the rectangle (or line) they make (including the border).
9 * 
10 * Return the count.
11 *  
12 * <strong class="example">Example 1:
13 * <div class="example-block">
14 * Input: <span class="example-io">points = [[1,1],[2,2],[3,3]]</span>
15 * Output: <span class="example-io">0</span>
16 * Explanation:
17 * <img src="https://assets.leetcode.com/uploads/2024/01/04/example1alicebob.png" style="width: 427px; height: 350px;" />
18 * There is no way to choose A and B so A is on the upper left side of B.
19 * </div>
20 * <strong class="example">Example 2:
21 * <div class="example-block">
22 * Input: <span class="example-io">points = [[6,2],[4,4],[2,6]]</span>
23 * Output: <span class="example-io">2</span>
24 * Explanation:
25 * <img height="365" src="https://assets.leetcode.com/uploads/2024/06/25/t2.jpg" width="1321" />
26 * 
27 * 	The left one is the pair (points[1], points[0]), where points[1] is on the upper left side of points[0] and the rectangle is empty.
28 * 	The middle one is the pair (points[2], points[1]), same as the left one it is a valid pair.
29 * 	The right one is the pair (points[2], points[0]), where points[2] is on the upper left side of points[0], but points[1] is inside the rectangle so it's not a valid pair.
30 * </div>
31 * <strong class="example">Example 3:
32 * <div class="example-block">
33 * Input: <span class="example-io">points = [[3,1],[1,3],[1,1]]</span>
34 * Output: <span class="example-io">2</span>
35 * Explanation:
36 * <img src="https://assets.leetcode.com/uploads/2024/06/25/t3.jpg" style="width: 1269px; height: 350px;" />
37 * 
38 * 	The left one is the pair (points[2], points[0]), where points[2] is on the upper left side of points[0] and there are no other points on the line they form. Note that it is a valid state when the two points form a line.
39 * 	The middle one is the pair (points[1], points[2]), it is a valid pair same as the left one.
40 * 	The right one is the pair (points[1], points[0]), it is not a valid pair as points[2] is on the border of the rectangle.
41 * </div>
42 *  
43 * Constraints:
44 * 
45 * 	2 <= n <= 50
46 * 	points[i].length == 2
47 * 	0 <= points[i][0], points[i][1] <= 50
48 * 	All points[i] are distinct.
49 * 
50 */
51pub struct Solution {}
52
53// problem: https://leetcode.com/problems/find-the-number-of-ways-to-place-people-i/
54// discuss: https://leetcode.com/problems/find-the-number-of-ways-to-place-people-i/discuss/?currentPage=1&orderBy=most_votes&query=
55
56// submission codes start here
57
58impl Solution {
59    pub fn number_of_pairs(points: Vec<Vec<i32>>) -> i32 {
60        0
61    }
62}
63
64// submission codes end
65
66#[cfg(test)]
67mod tests {
68    use super::*;
69
70    #[test]
71    fn test_3025() {
72    }
73}
74


Back
© 2025 bowen.ge All Rights Reserved.