Max points on a line problem (LeetCode

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ม.ค. 2025

ความคิดเห็น • 27

  • @Ruin3.14
    @Ruin3.14 ปีที่แล้ว +1

    This is my first hard problem, coming from a math background, i found this fairly easy. Thanks

  • @leamon9024
    @leamon9024 ปีที่แล้ว

    Thanks a looot! Love the way you explain. Looking forward to more videos about leetcode hard problems solving.

  • @fayezabusharkh3987
    @fayezabusharkh3987 2 ปีที่แล้ว +1

    Thank you you made this problem go from hard to easy

  • @jaatharsh
    @jaatharsh ปีที่แล้ว

    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.

  • @RajeshKumar-gz2vo
    @RajeshKumar-gz2vo 2 ปีที่แล้ว

    how do you make these animations?
    what tools do you use They are fantastic

    • @insidecode
      @insidecode  2 ปีที่แล้ว +1

      Thanks! I use PowerPoint for animations

  • @Samad_27
    @Samad_27 2 ปีที่แล้ว

    Can't wait for more videos 💛💛💛

  • @intelegixlabs
    @intelegixlabs 2 ปีที่แล้ว

    Awesome video, and explanation

  • @brucewayne6238
    @brucewayne6238 2 ปีที่แล้ว +1

    pls make a dynamic programming playlist

    • @insidecode
      @insidecode  2 ปีที่แล้ว

      Hello, I made a whole course on dp, link is in the description

    • @kbhanuprakash9530
      @kbhanuprakash9530 2 ปีที่แล้ว

      @@insidecode hey can you please make a video on this problem LEETCODE - 2152. Minimum Number of Lines to Cover Points

  • @saunaknandi1814
    @saunaknandi1814 2 ปีที่แล้ว

    what is the simplified fraction u are talking about I cant get it

    • @insidecode
      @insidecode  2 ปีที่แล้ว +1

      For example 16/20 is not simplified, 4/5 is its simplified fraction

  • @kbhanuprakash9530
    @kbhanuprakash9530 2 ปีที่แล้ว

    hey @Inside code can you please make a video on this problem LEETCODE - 2152. Minimum Number of Lines to Cover Points

  • @gunahawk6893
    @gunahawk6893 2 ปีที่แล้ว

    damn these animations good work

  • @moulee007
    @moulee007 2 ปีที่แล้ว

    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

  • @annubaba7944
    @annubaba7944 2 ปีที่แล้ว +2

    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

    • @joshavery
      @joshavery 2 ปีที่แล้ว +4

      Wouldn't this increase the time complexity to n^3

    • @brunocruzgranados55
      @brunocruzgranados55 2 ปีที่แล้ว

      @@joshavery that's right. It's another way to implement brute force

  • @AjithKumaR-jw9wt
    @AjithKumaR-jw9wt 2 ปีที่แล้ว

    Bro pls upload hashtable data structure and hashset waiting for longtime pls considered

  • @bmuralikrishna8054
    @bmuralikrishna8054 2 ปีที่แล้ว

    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.

  • @voorhs
    @voorhs 2 ปีที่แล้ว

    Good explanation, but bad solution, because it's O(n^3)

    • @insidecode
      @insidecode  2 ปีที่แล้ว +5

      No, it's in O(n²)

    • @jayneversettle
      @jayneversettle 2 ปีที่แล้ว +1

      Hey there are just two loops its n^2