this one and yesterday's problem where we assumed our array to be a linked list and tried to find the node where the loop starts (Leetcode 287: find the duplicate number) were kinda hard to think when solving for the first time. One thing I can surely note from this that if the value of integers is always less than the length of the array (or one less), we can use it as an index to the array. Thanks for the explanation!!
@nikoo288 ай бұрын
What was the programming contest you are referring to?
@jeet-smokeyАй бұрын
Man....this is unbelievable explanation. Kudos to your efforts...!!!! Thanks
@shivaniverma4266 Жыл бұрын
you are genus you are amazing you just smoothly put that logic in hour mind that in my dreams i can scream it lout all i am saying is whaattttttta content , you have such a great skills keeep doing , i am greatful for this channel
@nikoo28 Жыл бұрын
thank you so much for these kind and awesome words
@vanshbhatnagar1117 Жыл бұрын
class Solution { public: vector findDuplicates(vector& nums) { vector result ; for(int i=0; i
@deepeshreddy47003 жыл бұрын
Please don't stop uploading videos it is helping a lot for students like me
@nikoo283 жыл бұрын
Sure...do help me out by sharing this video as much as you can :)
@deepeshreddy47003 жыл бұрын
@@nikoo28 Okay
@abhi121able2 жыл бұрын
Superb Work. Explanation is too good. Very smooth :)
@chinmayjain97053 жыл бұрын
Heap sort can be use with space comp O(n). If 0(1) Arr[arr[i]%n ] = +n New arr[I] Again we will bring back original array by Arr[I]
@NikhilVerma-kk6xc Жыл бұрын
bhaisahab mst explaination
@ranchodas9 ай бұрын
Very well explained bro !!
@PRASANTH-if9se Жыл бұрын
why answer is repeating when they occur in the array more than 4 times
@utkarshjoshi2915 Жыл бұрын
Example taken in method 2, what if second occurrence of 3 is before 2(i.e, 2 and 3 change their positions of second occurrence, 2 at index 6 and 3 at index 5), at that situation , answer will not be in ascending order. Then we have to sort the returning array again ?
@shraddhajain89353 жыл бұрын
Really helpful. Thanks
@AyushMishra-b8w8 ай бұрын
don't you think you are using o(n) space by modifying the array itself
@unemployedcse35146 ай бұрын
space remains constant since , seperate or extra space is not utilised
@deliveringIdeas2 жыл бұрын
Thank you tremendously
@gauravmasalkar3546 Жыл бұрын
great work keep it doing
@sunshineandrainbow54533 ай бұрын
OG Explanation SIr ❤❤
@AmitChauhan-sp1cw2 жыл бұрын
how to implement code for returning -1 when repeating element does not exist?
@nikoo282 жыл бұрын
That will be a very small change in the code. If the resultSet is empty at the end, you can return a “-1”
@SanskarWankhede8 ай бұрын
great explanation
@choudharyhimanshu4134 Жыл бұрын
Can't we first sort the array and then iterate over the array and look for duplicates by comparing adjacent elements. Sorting will take O(nlogn) time and iteration will take O(n) time and no extra space is required. So, overall TC is O(n). Do correct me if I am wrong.
@ujjawalsharma1120 Жыл бұрын
Overall TC will be O(nlogn) here.
@AkashRK07 Жыл бұрын
Doesn't creating a result set consider as extra space?
@nikoo2811 ай бұрын
You are expected to return a result set, no need to count that. When we talk about space complexity, usually it is the extra space you would be needing.
@AkashRK0711 ай бұрын
@@nikoo28 understood 🙌🏻
@manishkumar-xc2zp2 жыл бұрын
why we have (index+1) , can anyone explain
@nikoo282 жыл бұрын
That is because the index ranges from 0 to (n-1) But the array elements are from 1 to n So if you do (index + 1) you are referring to the actual elements present in the array.
@pratikpatrimath4887 Жыл бұрын
superb 😎😎😎
@hemav998111 ай бұрын
If the element is 0 ,index becomes -1. It is showing array index out of bound error. How to solve this issue?
@vrishtiupadhyay502811 ай бұрын
Element will never be 0 as we have range from [1,n]
@hemav998128 күн бұрын
@@vrishtiupadhyay5028But what if we have such case?Because we are having a problem in GFG with array having 0 as a value
@sreddy81413 жыл бұрын
Bhai, wanna know about desktop space analysis problem
@nikoo283 жыл бұрын
I can’t find the link to the problem. Reach out to me on my email available in channel information.
@rajkumarp9943 Жыл бұрын
Good 💥
@prabaljana9714 Жыл бұрын
If the element encounted 0 the. What to do
@nikoo28 Жыл бұрын
Then you will have to handle the 0 differently. For this particular problem check the constraints: 1
@nikhilbansal373110 ай бұрын
What is name of the approach
@nikoo2810 ай бұрын
I don't know if there is a specific name to this approach
@suryav8458 Жыл бұрын
Please some times name the Alogrithm name also otherwise everything is good
@nikoo28 Жыл бұрын
not every algorithm has a name, and your interviewer will never ask the algorithm name.
@chinmayjain97053 жыл бұрын
👍
@ujjawalsharma1120 Жыл бұрын
it will not give sorted array for this input n = 8, 4 3 2 4 8 2 3 1, how to fix it, pls correct me if input is not valid.
@nikoo28 Жыл бұрын
What do you mean by not giving a sorted array? You are looking for duplicates..right??