Check if it is a straight Line | LeetCode 1232 | C++, Java, Python | May LeetCoding Day 8

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ต.ค. 2024

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

  • @KnowledgeCenter
    @KnowledgeCenter  4 ปีที่แล้ว +1

    ERROR in get_slope() function, if x values are same, then we should return greater than 20k as discussed in video. It was missed out while writing the code. Here is the corrected code:
    get_slope( p1, p2){
    if(p1[0] == p2[0])
    return 40000;

  • @sanghitasaha8346
    @sanghitasaha8346 4 ปีที่แล้ว +1

    Thank you sir for your videos. I follow it regularly. Your explanation is very easy to understand the problem. All the best.
    Regards
    Sanghita

  • @mohamedbasharulkhan7520
    @mohamedbasharulkhan7520 4 ปีที่แล้ว +1

    Thanks dude!!

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

    Great work!!!!! Just a minor error...you forgot to check for if y are equal... that is->if(p1[0]==p2[0]||p1[1]==p2[1]){
    return 1000000000000; line 14 correction..Great content!!!

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

      Oh. I see the error now... For same x it should be > 20k.
      Thanks.

    • @KnowledgeCenter
      @KnowledgeCenter  4 ปีที่แล้ว +1

      float get_slope(vector& p1, vector& p2){
      if(p1[0] == p2[0])
      return 40000;
      return (float)(p2[1] - p1[1])/(p2[0] - p1[0]);
      }

    • @KnowledgeCenter
      @KnowledgeCenter  4 ปีที่แล้ว +1

      Added the CORRECTION in video description and comments section. That was a miss...

    • @BarkaDog
      @BarkaDog 4 ปีที่แล้ว

      Why do you want to check if y is equal?

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

    Hi brother, im just a beginner in java what are the steps i have ro follow leetcode problems
    Plz explain sir.

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

      Get familiar with basic data structures- Arrays, Linked List, Has Map, Trees, etc..

  • @abhisheksharma7668
    @abhisheksharma7668 4 ปีที่แล้ว

    Can anyone explain me the purpose of taking the very large number when the divisor become 0. It solve the problem, but how does it solve the problem, I am not much clear about it.