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.
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.
Pseudocode:
1: sort
2: using loop
3: check previous and current is same or different
4: return the same value
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;
can't you also set negative numbers at the index, and if you come across a negative value, that's the dupe?
Awesome
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.
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.
This is a good explanation. Btw, what kind of drawing software you are using? Is it on mac?
I use explaineverything.
Ohh i get thanks for the video
can you make the in high volume it very difficult to hear you
I dont get why fast is going back to 4
because the index of the last "2" is "4". Same way as the first "2" points to "4".