diff --git a/cpp/0149-max-points-on-a-line.cpp b/cpp/0149-max-points-on-a-line.cpp new file mode 100644 index 000000000..413f6a396 --- /dev/null +++ b/cpp/0149-max-points-on-a-line.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + int maxPoints(vector>& points) { + int res = 1; + for (int i=0; i count; + for (int j=i+1; j& p1, vector& p2) { + if ((p2[0] - p1[0]) == 0) + return INT_MAX; // aka edge case to handle a slope of infinity + return (float) (p2[1] - p1[1]) / (float) (p2[0] - p1[0]); + } +}; \ No newline at end of file