Points on the Straight Line - Java

MEDIUM JAVA

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

Sample Input I :
(1, 1) (2, 2)

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

Sample Input I :
(1, 1) (2, 2)

Sample Output I :
2

Sample Input  II :
(1, 1) (2, 2) (3, 3) (4, 5)

Sample Output II :
3

You will be given 2 arrays X and Y. Each point is represented by (X[i], Y[i])
Your Input :
(11,12)
(13,14)
(21,34)
(43,56)

Sample Output I :
2

Sample Input  II :
(41, 51) (62, 73) (80, 91)

Sample Output II :
2

You will be given 2 arrays X and Y. Each point is represented by (X[i], Y[i])
Your Input :
(11,12)
(13,14)
(21,34)
(43,56)


Submit Answer

NOTE These questions can be solved in either Java , Python , Rust, C++, Go or ! However, the language intended for these questions is mentioned along with the question on the top. You need to submit the solution file for the autograder to grade the submission. If you are submitting in Java, make sure that the class name is Main (with a capital M)


Optional Java Editor for your use