as always great expain nivedita di thanks for all these videos and lovely explaination. Di I have a doubt does a more optimised solution exist for this question or not??
Hi Vivek, just include a condition else if(points[i][1] == points[j][1]) and put a dummy value like -10001.... as the points may also lie in the same y axis.
Good work 👍
Thank you :)
Thanks... v easy explanation... and so simple code ... like it.
Most simplest explanation great help for the beginners . Thank you for uploading such great content
Here is hidden gem of DSA on youtube 🤭🤭🤭
didi your solution is very easy to understand✌✌
Glad to hear that
very helpful videos
Glad you think so!
abhi tak ka sabse easy explanation. koi bhi youtube channel itna perfect explanation nhi kiya.. thank u diiiiii
Welcome :) must recommend my channel to your friends
great explaination
Your Explanation is Good
beautiful explanation with loving voice keep doing🥰🥰
Thank you :) Must share
As expected fast and easy solution with best explanation.
keep your consistency.
Thank you :) sure
Great consistency!! Thank you for providing solutions in both my fav langs : Hindi and C++
Welcome :) keep watching and sharing
You are doing a great job👍
Thank you :)
as always great expain nivedita di thanks for all these videos and lovely explaination.
Di I have a doubt does a more optimised solution exist for this question or not??
Thanks for explaining so nicelyy!!
Can anyone help me with java code: I'm getting wrong output in the test case:
points =
[[2,3],[3,3],[-5,3]]
Output
2
Expected
3
class Solution {
public int maxPoints(int[][] points) {
int maxPoints = 0;
for (int i = 0 ; i < points.length-1 ; i++) {
HashMap hm = new HashMap();
for (int j = i+1 ; j < points.length ; j++) {
if (points[i][0] == points[j][0]) {
hm.put(Double.valueOf(10001), hm.getOrDefault(Double.valueOf(10001), 0) + 1);
}
else {
double slope = (double)(points[j][1]-points[i][1])/(double)(points[j][0]-points[i][0]);
hm.put(slope, hm.getOrDefault(slope, 0) + 1);
}
}
for (int occurences : hm.values()) {
maxPoints = Math.max(maxPoints, occurences+1);
}
}
return Math.max(1, maxPoints);
}
}
Hi Vivek, just include a condition else if(points[i][1] == points[j][1]) and put a dummy value like -10001.... as the points may also lie in the same y axis.
@@tejasc7409 Thanks a lot Tejas for explaining, It worked ❤
Thank you:)