Why do all solutions ignore the "b" in "y = ax + b"?

  • 0

    Every solution in the discussion is comparing two lines by looking at their slope. But the formula for a line is "y = ax + b", you can't just look at the slope, you also have to look at the offset. That is, the line from (0,0 to 1,1) has the same slope as the line from (1,0 to 2,1) but seems to me they aren't on the same line in the plane, so you have to include the "b" constant.
    But every solution here seems to ignore that "b" constant. I'm outvoted, so I'm sure I'm wrong and the crowd is right; but why? Why is everyone able to ignore that constant in these solutions?

  • 0

    Look at those solutions carefully and you will see why.
    There are many ways to explain the idea, here is one:
    For each point p, you first translate all points by -p, and then count the points with the same slope. (in this way b = 0 in the formula y=ax+b. Moreover, I suggest using a more general line function, ax+by+c=0, which includes the vertical case)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.