149. Max Points on a Line Hard
1/**
2 * [149] Max Points on a Line
3 *
4 * Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.
5 *
6 * Example 1:
7 * <img alt="" src="https://assets.leetcode.com/uploads/2021/02/25/plane1.jpg" style="width: 300px; height: 294px;" />
8 * Input: points = [[1,1],[2,2],[3,3]]
9 * Output: 3
10 *
11 * Example 2:
12 * <img alt="" src="https://assets.leetcode.com/uploads/2021/02/25/plane2.jpg" style="width: 300px; height: 294px;" />
13 * Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
14 * Output: 4
15 *
16 *
17 * Constraints:
18 *
19 * 1 <= points.length <= 300
20 * points[i].length == 2
21 * -10^4 <= xi, yi <= 10^4
22 * All the points are unique.
23 *
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/max-points-on-a-line/
28// discuss: https://leetcode.com/problems/max-points-on-a-line/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33 pub fn max_points(points: Vec<Vec<i32>>) -> i32 {
34 0
35 }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn test_149() {
46 }
47}
48
Back
© 2025 bowen.ge All Rights Reserved.