LeetCode 149: Max Points on a Line I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time!
Problem
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
Example 1:

Input: [[1,1],[2,2],[3,3]]
Output: 3


^
|
|        o
|     o
|  o  
+-------------&gt;
0  1  2  3  4


Example 2:

Input: [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
Output: 4

^
|
|  o
|     o        o
|        o
|  o        o
+-------------------&gt;
0  1  2  3  4  5  6

Inputs
[[1,1],[2,2],[3,3]]
[[0,0],[94911151,94911150],[94911152,94911151]]
[[1,1],[2,2],[3,3],[131,131],[3111,3111],[31,31],[13,13],[113,11],[5,5]]

Outputs
3
2
8

Code
#include &lt;vector&gt;
#include &lt;map&gt;
#include &lt;utility&gt;
#include &lt;algorithm&gt;

struct Solution {
    static const inline int maxPoints(const std::vector&lt;std::vector&lt;int&gt;&gt; &amp;points) {
        int max_points = 0;

        for (int index_i = 0; index_i &lt; points.size(); index_i++) {
            int overlap = 0;
            int y_on = 0;
            int curr = 0;
            map&lt;pair&lt;int, int&gt;, int&gt; points_map;

            for (int index_j = index_i + 1; index_j &lt; points.size(); index_j++) {
                if (points[index_i] == points[index_j]) {
                    overlap++;

                } else if (points[index_i][0] == points[index_j][0]) {
                    y_on++;

                } else {
                    const int x = points[index_i][0] - points[index_j][0];
                    const int y = points[index_i][1] - points[index_j][1];
                    const int gcd = greatest_common_divisor(x, y);
                    points_map[ {x / gcd, y / gcd}]++;
                    curr = std::max(curr, points_map[ {x / gcd, y / gcd}]);

                }

                curr = std::max(curr, y_on);
            }

            max_points = std::max(max_points, curr + overlap + 1);
        }

        return max_points;
    }

private:
    // std::gcd
    static inline const int greatest_common_divisor(const int a, const int b) {
        if (not b) {
            return a;

        } else {
            return greatest_common_divisor(b, a % b);
        }
    }
};


References

Problem

Discuss

Solution
Code Review

Prefer int to const inline int. See Previous review.

Prefer to pass by const reference

Prefer to put the &amp; next to the type (not the parameter).
Its part of the type information (note this is the opposite of C).
  static const inline int maxPoints(const std::vector&lt;std::vector&lt;int&gt;&gt; &amp;points)




This is absolutely fine (I have not problems with it).
        int max_points = 0;

But most (I have no real metrics for this, but in my experience) tend to use &quot;CamelCase&quot; rather than &quot;Snake_Case&quot; naming convention.

Prefer to use pre-increment rather than post increment
        for (int index_i = 0; index_i &lt; points.size(); index_i++) {

The reason is that C++ code can simply be changed by changing the type used. Now pre/post fix increment on an integer has exactly the same type. But if we change the type used for the iterator then pre/post increment can be slightly different in cost. The standard implementation of iterators (the most common thing used in loops) will give you a slightly more expensive operation (in theory) than a pre-increment. Thus the standard advice is to always use the pre-increment to make sure you always use the most efficient operation.

Be aware of the new range based operator.
Not sure it totally helps here. But keep in mind the range based operator:
        for (int index_i = 0; index_i &lt; points.size(); index_i++) {
            auto&amp; item = points[index_i];

            // STUFF
        }

        // can be simplified to:
        for (auto&amp; item: points) {

            // STUFF
        }


Your assuming that using namespace std; is somewhere above you.
            map&lt;pair&lt;int, int&gt;, int&gt; points_map;

Don't. Even using using namespace std; is considered bad pactice.

Not very common to see the use of not. It is much more common to use !.
        if (not b) {

        ----

        if (!b) {

For most C developers this will be the normal.