lovely thanks buddy, keep up the good work 👍 Also python averse people make sure the slope and intercept you are calculationg is in double to avoid wasting time debugging last few TestCases.
brute force solution: class Solution: def maxPoints(self, points: List[List[int]]) -> int: n = len(points) res = 0 if n == 1: return 1 for i in range(0,n): for j in range(i+1,n): count = 2 dx = points[j][0] - points[i][0] dy = points[j][1] - points[i][1] for k in range(0,n): if k!=i and k!=j: dy_ = points[k][1] - points[j][1] dx_ = points[k][0] - points[j][0]
if dx*dy_ == dy*dx_: count +=1 res = max(res,count) return res
If you want to ignore floating point errors , go another way : Find area of triangle by three points , if its non zero , then they aren't on same line , else they are on same line . Check this thing with every pair , and find MAX
Concept is good & explanation is excellent but implementation is complex. May be in python it might be easy to implement but in languages like c++ & Java , it's hard to implement this approach.
This is my first hard problem, coming from a math background, i found this fairly easy. Thanks
Thanks a looot! Love the way you explain. Looking forward to more videos about leetcode hard problems solving.
Thank you you made this problem go from hard to easy
lovely thanks buddy, keep up the good work 👍
Also python averse people make sure the slope and intercept you are calculationg is in double to avoid wasting time debugging last few TestCases.
how do you make these animations?
what tools do you use They are fantastic
Thanks! I use PowerPoint for animations
Can't wait for more videos 💛💛💛
Awesome video, and explanation
Thanks!
pls make a dynamic programming playlist
Hello, I made a whole course on dp, link is in the description
@@insidecode hey can you please make a video on this problem LEETCODE - 2152. Minimum Number of Lines to Cover Points
what is the simplified fraction u are talking about I cant get it
For example 16/20 is not simplified, 4/5 is its simplified fraction
hey @Inside code can you please make a video on this problem LEETCODE - 2152. Minimum Number of Lines to Cover Points
damn these animations good work
Thanks!
brute force solution:
class Solution:
def maxPoints(self, points: List[List[int]]) -> int:
n = len(points)
res = 0
if n == 1:
return 1
for i in range(0,n):
for j in range(i+1,n):
count = 2
dx = points[j][0] - points[i][0]
dy = points[j][1] - points[i][1]
for k in range(0,n):
if k!=i and k!=j:
dy_ = points[k][1] - points[j][1]
dx_ = points[k][0] - points[j][0]
if dx*dy_ == dy*dx_:
count +=1
res = max(res,count)
return res
If you want to ignore floating point errors , go another way :
Find area of triangle by three points , if its non zero , then they aren't on same line ,
else they are on same line .
Check this thing with every pair , and find MAX
Wouldn't this increase the time complexity to n^3
@@joshavery that's right. It's another way to implement brute force
Bro pls upload hashtable data structure and hashset waiting for longtime pls considered
Concept is good & explanation is excellent but implementation is complex. May be in python it might be easy to implement but in languages like c++ & Java , it's hard to implement this approach.
Good explanation, but bad solution, because it's O(n^3)
No, it's in O(n²)
Hey there are just two loops its n^2