Geeksforgeeks

Error

Given two arrays **X[] **and **Y[]** of points where (**X _{i}, Y_{i}**)

**Example 1:**

**Input:**
X[] = {1, 2, 3}
Y[] = {1, 2, 3}
**Output: **3
**Explanation:
**The points are** **(1,1),** **(2,2)** **and** **(3,3).**
**

**Example 2:**

**Input:
**X[] = {1, 3, 5, 4, 2, 1}
Y[] = {1, 2, 3, 1, 3, 4}
**Output: **4
**Explanation:
**The points are-
(1,1),(3,2),(5,3),(4,1),(2,3),(1,4)

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **maxPoints****()** which takes two lists of coordinates as input and returns the maximum number of points that lies on the same line.

**Expected Time Complexity:** O(N^{2})

**Expected Auxiliary Space:** O(N)

**Constraints:**

1 <=** N **<= 300

-10^{4} <= **x _{i}, y_{i}** <= 10

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Points in Straight Line

...