problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::max_points_on_a_line::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int maxPoints (vector< vector< int > > &points)
 

详细描述

在文件 leetcode.h2547 行定义.

成员函数说明

◆ maxPoints()

int leetcode::max_points_on_a_line::Solution::maxPoints ( vector< vector< int > > &  points)
static

在文件 leetcode.cpp6850 行定义.

6850 {
6851 int ans = 0;
6852 for(auto &p1: points) {
6853 unordered_map<long double, int> us;
6854 int cnt = 0;
6855 for(auto &p2: points) {
6856 if(p2[0] != p1[0]) {
6857 us[static_cast<long double>(p2[1] - p1[1]) / static_cast<long double>(p2[0] - p1[0])]++;
6858 } else {
6859 cnt++;
6860 }
6861 }
6862 for(auto &[k, v]: us) {
6863 cnt = max(cnt, v + 1);
6864 }
6865 ans = max(ans, cnt);
6866 }
6867 return ans;
6868 }

被这些函数引用 leetcode::max_points_on_a_line::TEST().


该类的文档由以下文件生成: