LEETCODE 287 (JAVASCRIPT) | FIND THE DUPLICATE NUMBER

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

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

  • @Guts狂暴
    @Guts狂暴 ปีที่แล้ว +1

    Pseudocode:
    1: sort
    2: using loop
    3: check previous and current is same or different
    4: return the same value

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

    Hi Andy, Why did we not take the gsum approach here?: gSum = ((n-1)*(n)) / 2; nSum = nums.reduce((acc+el) => acc + el, 0); result = nSum - gSum;

  • @thethirddan
    @thethirddan 10 วันที่ผ่านมา

    can't you also set negative numbers at the index, and if you come across a negative value, that's the dupe?

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

    Awesome

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

    I understand the idea when you explain the algo, however, what made you think about using the floyd algo in the first place? You mentioned length n + 1 and the range [1, n] , but it is not clear why u chose this solution based on the length and range.

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

    Great videos Sir!
    Very nice explanations.
    But I have a query here: I tried with this solution for the input: [1,3,4,5,4] and its returning 'undefined'.
    Can you please help me on this.

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

    This is a good explanation. Btw, what kind of drawing software you are using? Is it on mac?

    • @andygala888
      @andygala888  3 ปีที่แล้ว

      I use explaineverything.

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

    Ohh i get thanks for the video

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

    can you make the in high volume it very difficult to hear you

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

    I dont get why fast is going back to 4

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

      because the index of the last "2" is "4". Same way as the first "2" points to "4".