[LC 149] Max points on a line

Drawing a picture with several points is helpful. For each point, find out the line determined by itself and every other point. Usually a line a determined by k and b, such that y = kx+b. Here, because one point is fixed, each line can be determined by k, which is (p2.y – p1.y) / (p2.x – p1.x), which is a double type number. So to remember all the lines for each one of the point, we can either use k (the double type) as the key, or use two integers p2.y – p1.y and p2.x – p1.x, and divide both numbers by their greatest common divisor.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s