Detect overlapping circle | Uber Frontend Interview Question | Q-30

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

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

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

    Tough one this will really test your FE skills

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

    Thanks a lot for this video, I tried the same code given in description, I notice one issue here , if draw 2 circle near each other it turned into green but it didn't overlap, here the issue is of border radius, I went into console , removed border radius then found that these 2 square are overlapping, it would much helpful if you let us know how to handle this.

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

      Update the calc for detecting collision

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

    This is really helpful, thank you

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

    I dont get why we need to use prevState?
    Why were we not allowed to access the earlier state?
    Any links would be helpful

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

      stackoverflow.com/questions/55817787/access-state-from-event-handler-created-within-react-js-useeffect-hook

  • @anujnandwana726
    @anujnandwana726 2 หลายเดือนก่อน +2

    The condition is not correct for circle. Two circles will intersect if the difference between their radius is smaller than the distance separating their centers :
    correct answer is :
    const distance = Math.sqrt(
    (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)
    );
    if ( distance -r1 - r2

    • @Learnersbucket
      @Learnersbucket  2 หลายเดือนก่อน

      Check the code yourself

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

    How to add those drag features?

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

      That you have to practice, calculate the difference in position between mouse click and mouse move

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

    There is a typo in thumbnail

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

    Some Test cases are failed

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

      Which cases?

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

      @@Learnersbucket If you check the last circle which is drawn, it is not colliding but still it shows green color

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

      @@hathigamingyt3796 there is a Codepen link, please test yourself once

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

      @@Learnersbucket Yeah, the overlap detection logic isn't working well. I have tried it on the shared codepen link. Below is the screenshot for the same
      i.snipboard.io/FMZlp2.jpg