149. Max Points on a Line

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 25

  • @mintusharma7211
    @mintusharma7211 Рік тому +2

    Good work 👍

  • @shreyasyaduvanshi
    @shreyasyaduvanshi 2 місяці тому

    Thanks... v easy explanation... and so simple code ... like it.

  • @pavankumarreddyms531
    @pavankumarreddyms531 Рік тому

    Most simplest explanation great help for the beginners . Thank you for uploading such great content

  • @Manish-ww3lg
    @Manish-ww3lg Рік тому +3

    Here is hidden gem of DSA on youtube 🤭🤭🤭
    didi your solution is very easy to understand✌✌

  • @abhaythakur2597
    @abhaythakur2597 Рік тому +2

    very helpful videos

  • @shubhamkumarraj4990
    @shubhamkumarraj4990 Рік тому +1

    abhi tak ka sabse easy explanation. koi bhi youtube channel itna perfect explanation nhi kiya.. thank u diiiiii

  • @pranavpranjal2717
    @pranavpranjal2717 6 місяців тому

    great explaination

  • @Shiv_Indian
    @Shiv_Indian Рік тому

    Your Explanation is Good

  • @amitshankhwar2542
    @amitshankhwar2542 Рік тому +2

    beautiful explanation with loving voice keep doing🥰🥰

  • @005_adarshprajapati9
    @005_adarshprajapati9 Рік тому +1

    As expected fast and easy solution with best explanation.
    keep your consistency.

  • @AR-py5uk
    @AR-py5uk Рік тому +4

    Great consistency!! Thank you for providing solutions in both my fav langs : Hindi and C++

  • @jayarani9254
    @jayarani9254 Рік тому +1

    You are doing a great job👍

  • @satyamgupta6030
    @satyamgupta6030 Рік тому

    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??

  • @vivekishore
    @vivekishore Рік тому +1

    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);
    }
    }

    • @tejasc7409
      @tejasc7409 Рік тому +1

      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.

    • @vivekishore
      @vivekishore Рік тому +1

      @@tejasc7409 Thanks a lot Tejas for explaining, It worked ❤

    • @techadorabynivedita
      @techadorabynivedita  Рік тому +2

      Thank you:)