Тёмный

Coding Interview Question | Find one/two Missing Numbers in Array | XOR application 

Keerti Purswani
Подписаться 140 тыс.
Просмотров 40 тыс.
50% 1

Опубликовано:

 

11 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 91   
@shwetajha8745
@shwetajha8745 3 года назад
I found this channel today. I absolutely loved your explanation.
@padarthiharibabu9412
@padarthiharibabu9412 4 года назад
Thanks for introducing new weapon called xor.
@pradeepanand5296
@pradeepanand5296 Год назад
was looking for solution of missing and repeating number and this video gives the approach of that as well.
@abhijeetsoni1978
@abhijeetsoni1978 3 года назад
Found great video after a long time on DS. Explanation is very good and to the point. Thanks for posting, keep going! 😃
@KeertiPurswani
@KeertiPurswani 3 года назад
Thank you so much Abhijeet 😇😇
@udayptp
@udayptp 2 года назад
🥰 grt approach, another similar type ques is find one missing and one repeating number in array.
@alphonseprakash7459
@alphonseprakash7459 3 года назад
one video with so many approaches simply great. ☺
@backbencher304
@backbencher304 2 года назад
I fall in problem suru m smz aa rha tha bt last tak aate aate mujhe ghar jane do wali condition aa gyi bt I appreciate ur efforts thanks
@easycode7807
@easycode7807 2 года назад
similar question was asked me in the interview like : given array of elements from 141 to 240 of an unsorted array. in this array, 2 numbers are missing ... find those two numbers with Max time complexity: O(N) .. N is the size of the input array.
@ShivamKumar-hi3pl
@ShivamKumar-hi3pl 4 года назад
Please make more videos like this👌👌
@maheswarishanthi9729
@maheswarishanthi9729 Год назад
Was looking for solution of missing repeating number and this video gives the apporach as well.
@akashgupta13
@akashgupta13 4 года назад
Nice Explanation
@SonijiCoding934
@SonijiCoding934 4 месяца назад
Well Explanation is good but if you can show us how can we implement these logic in the code it will give the viewer better understanding.
@rajeshdas2295
@rajeshdas2295 Год назад
Keerti you nailed it. tremendous explanation!!!!!
@blackmouthblackface
@blackmouthblackface 2 года назад
Thank you for the video. Would've really liked to see you implement the brute force approach and talk more about how you would figure out the missing number using hash map or vector as you didn't mention how you would keep track of which number was missing given an unsorted array.
@bhawna1997
@bhawna1997 2 года назад
The moment I saw the video I could recognize her from the Google Interview video she gave which was so good!
@venkateshpachigulla
@venkateshpachigulla 3 года назад
The xor concept is interesting but how can we implement in program? Explain the same in writing program or send program link if already there.
@subrochakraborty137
@subrochakraborty137 3 года назад
This same solution is everywhere throughout the net, it seems like every other ds/algo youtube channel came with the same solution. How do we get the intuition to use xor? Can you provide some other problem similar to this where xor can be used so that we understand how to approach the problem better.
@santanupradhan5017
@santanupradhan5017 2 года назад
You can try the problem, in an array every number appers twice except two. Find the two numbers which appers once.
@rushikmakwawna
@rushikmakwawna 3 года назад
Like the way you started with simple solutions and loop holes in that and keep on improving solution. Good work for bringing up such video!
@KeertiPurswani
@KeertiPurswani 3 года назад
Thanks, this is how we can really build the thinking process for interviews 😇
@josiahdavid7735
@josiahdavid7735 2 года назад
Thank you for this video, the explanation helped solidify my understanding of XOR.
@j-espresso
@j-espresso 3 года назад
Suppose the input array had negative elements e.g. A{1, -2, 4, -5, 6} how would you find a missing element?
@sagarlandge3271
@sagarlandge3271 3 года назад
Your input is invalid, it should have elements from 1 to n with 1(or 2) elements missing
@maheswarishanthi9729
@maheswarishanthi9729 Год назад
Nice explanation. I would not have thoughts of it
@punitgoel37
@punitgoel37 2 года назад
Hi Keerti , nice explanation, have a query from the interviewer perspective, do you really expect a candidate to solve this in interview if he hasn't seen the question before ?
@yelururao1
@yelururao1 4 года назад
Nice explanations..
@geeksentertainmentmedia4827
@geeksentertainmentmedia4827 4 года назад
Nice explanation.
@pranavbapat1909
@pranavbapat1909 Год назад
Superb...
@ShivamKumar-hi3pl
@ShivamKumar-hi3pl 4 года назад
Thanks for great explanation👍
@RitikKumar-bk6pj
@RitikKumar-bk6pj 2 года назад
Thank u mam nice explanation of this problem solution and again thank u for making this video..
@AceH-oe3nx
@AceH-oe3nx 5 месяцев назад
Can we extend your solution for finding 3 missing numbers?
@saiadityaede6679
@saiadityaede6679 4 года назад
thanks for the upload
@chintamalli695
@chintamalli695 3 года назад
Thanks a lot , One of the best class
@sneha_2005
@sneha_2005 4 года назад
Great explanation! Also, could you please share the link of a question using this concept, so that we could implement the logic. Thanks. :)
@KeertiPurswani
@KeertiPurswani 4 года назад
Have added link to "1 number missing" question in description. I couldn't find the "2 numbers missing" question on LeetCode/Hackerrank but I have personally experienced this question being asked a lot and it is present on geeksforgeeks. Since it requires just an array input, I recommend you to practise it on any ide you are comfortable with :)
@sneha_2005
@sneha_2005 4 года назад
@@KeertiPurswani Thanks, will surely practice. :)
@KeertiPurswani
@KeertiPurswani 3 года назад
The averag of 2 and 4 is 3. 2 is smaller than 3 and 4 is bigger 🙂
@unmeshchougule5666
@unmeshchougule5666 2 года назад
Hello, So in the interview is it fine if we do not derive any solution and just use this pre derived formula and solve the problem? I mean there is no reasoning we can give why this works.
@abhigyansharma9108
@abhigyansharma9108 3 года назад
Yaar didi aaap itna accha pdhati ho.. Koi course hota na Mai pkka le leta.. ❤❤❤ Didi itna bdhia padhaya yh aapne .. Didi ek dikkat h maine aapse Median of sorted array bhi smjha tha 2-3 mahine phle tab sab smjh aya lekin ab mai code nhi krpaunga aisa kyu😔... How to deal with this Please
@krishnavar7219
@krishnavar7219 Год назад
you have done great work
@devprakash5320
@devprakash5320 3 года назад
Learnt something new today
@dev-skills
@dev-skills 8 месяцев назад
Watch with 1.5x and skip till 00:08:00 for the best solution.
@akasnani3464
@akasnani3464 4 года назад
Keep it up
@mangeshgupta5677
@mangeshgupta5677 4 года назад
great explaination thank you
@KeertiPurswani
@KeertiPurswani 4 года назад
Glad you liked it :)
@ANUJKUMAR-wc9dz
@ANUJKUMAR-wc9dz 2 года назад
int arr[] = {2,3,4}; for this array how first approach is valid ?
@vivaciousjiten
@vivaciousjiten 3 года назад
Hi , thanks for the explanation , do we have to have number starting from 1 or can it be find missing 1 number from (90,91,94,93) as well ?
@ShivamVerma-gq2sm
@ShivamVerma-gq2sm 3 года назад
please read the question you will understand the context.
@prabhanshusharma1337
@prabhanshusharma1337 3 года назад
Nice explanation Keerti. I wouldn't have thought of XOR approach.
@iiRaiku
@iiRaiku 2 года назад
amazing
@durgeshchaudhary1158
@durgeshchaudhary1158 2 года назад
Thanku so much 💕
@technofun80
@technofun80 3 года назад
Video is really great. Please make tgese kind of videos so that it will be helpful.
@KeertiPurswani
@KeertiPurswani 3 года назад
For sure. So many coming up!!😇
@ajaychaudhari599
@ajaychaudhari599 2 года назад
i am your new subcriber mam or sister..
@salmankhatik4985
@salmankhatik4985 2 года назад
but how code this in java
@kmuralikrishna2857
@kmuralikrishna2857 3 года назад
learned something new today
@KeertiPurswani
@KeertiPurswani 3 года назад
Mission accomplished 🙂
@saunaknandi1814
@saunaknandi1814 2 года назад
Why u dont show the code
@ambrish8144
@ambrish8144 4 года назад
how just by classifying the numbers based on right most set bit helps in finding the number i did not understand it logically please can anyone explain
@Deepak-gj4ni
@Deepak-gj4ni 3 года назад
Here iam again 😂 in search of xor concept this time
@anubhav5709
@anubhav5709 2 года назад
the second method of finding two missing number is valid for unsorted array...???????????
@josiahdavid7735
@josiahdavid7735 2 года назад
yes
@NeerajSharma-zs7xq
@NeerajSharma-zs7xq 2 года назад
We are not looking for mathematical logic
@babuaprem6140
@babuaprem6140 Год назад
theory toh de dete ho par code kaha hai
@jamesperalta2870
@jamesperalta2870 3 года назад
Great video!
@KeertiPurswani
@KeertiPurswani 3 года назад
Thanks 😇
@siddharthkeshri5649
@siddharthkeshri5649 3 года назад
XOR u beauty 🔥mast one mam❤️👍
@KeertiPurswani
@KeertiPurswani 3 года назад
Thanks Siddharth 😊😊
@chintamalli695
@chintamalli695 3 года назад
It would be great if you create git
@pankajmenaria3230
@pankajmenaria3230 3 года назад
i still have a confusion how you calc N ?
@pankajmenaria3230
@pankajmenaria3230 3 года назад
can you explan in code
@shivangisrivastava1158
@shivangisrivastava1158 3 года назад
Please please explain the code of XOR , I can't find its explanation anywhere on YT.
@KeertiPurswani
@KeertiPurswani 3 года назад
Added to my list!
@josiahdavid7735
@josiahdavid7735 2 года назад
I have a more intuitive solution that uses O(N) time complexity and O(1) space. The drawback is that in my opinion her concept sounds cleaner. but this approach is good too; read below: We have an array of N elements in range(1, N) and 2 elements are missing how do we find the values of the 2 elements? The idea behind this method is that it leverages on the fact that the array is in range (1,N) elements. So we can use the indexes of the elements and find the elements that are missing. As we traverse the array the value of an element at an index we negate the element at the corresponding index that equals that value. When we are done we traverse the array again looking for positive elements any positive element we find its index is a missing element. Now the part that makes me say its a draw back is that before we do the above we have to traverse the array looking for N-1th element and the Nth element because we do not want to get an index error in our array. let me give an example to make everything clear. A = [3,1,5,6] This array A is in range 1 - 6. We traverse looking for 6 and 5 . We find both 6 and 5 in the array. Why do we look for both of them first? because looking for A[5-1] or A[6-1] would give us an error. So we continue we traverse the second time A[0] == 3, A[3-1] ==5 we negate 5 , next iteration A[1] == 1, A[1-1] == 3 so we negate 3 next iteration A[2] == 5 since we get 5 we skip to next iteration because it would give us an error. next iteration A[3] == 6 since we get 6 we skip to next iteration and then we're done. so our array would look like this A = [-3, 1, -5, 6]. Now since we have this array we traverse once more looking for positive numbers any positive number we find its index is a missing number. so the index of 1 and 6 are the missing numbers. 2 and 4. Take note of the zero-error because numbers start from 1 not zero.
@rajpalmanda5250
@rajpalmanda5250 2 года назад
Code bta dimag to mene lga liya tha kese hoga ,code nhi aata 🤦🤦🤦
@anuj654
@anuj654 3 года назад
Book pad rhi ho ?
@wewarntogether
@wewarntogether 3 года назад
6:33 not true what if i take out 1 and 3 from 123456?
@KeertiPurswani
@KeertiPurswani 3 года назад
Why are you taking out 1 and 3? I am talking about 2 numbers and their average at 6:33🤷🤷
@sagestudy
@sagestudy 2 года назад
Who the he*k marked this question easy on Leet Code?
@mcaddit6802
@mcaddit6802 3 года назад
Are you sindhi?
@KeertiPurswani
@KeertiPurswani 3 года назад
Yup!
@pranavkorhale5089
@pranavkorhale5089 2 года назад
[JAVA CODE] public class Main { public static void main(String[] args) { int []arr = {1,2,4,6}; int n = arr.length+2; int asum = n*(n+1)/2; int csum = 0; for(int ele:arr) csum+=ele; int diff = asum-csum; int avg = diff/2; int firstele = 0; int secele = 0; for(int i=1;i
@dgod245
@dgod245 Год назад
damn she bad
@NaveenKumar-ep6dz
@NaveenKumar-ep6dz 3 года назад
do the programs in such a way user gives the input
@KeertiPurswani
@KeertiPurswani 3 года назад
What do you mean?
@NaveenKumar-ep6dz
@NaveenKumar-ep6dz 3 года назад
@@KeertiPurswani instead of taking direct values use user defined for other programs
@NaveenKumar-ep6dz
@NaveenKumar-ep6dz 3 года назад
@@KeertiPurswani can u make video on functions and recursion's with examples
@enchantularity
@enchantularity Год назад
But mam, you started with finding 2 missing numbers. Please upload
Далее
How I Got Good at Coding Interviews
6:29
Просмотров 1,6 млн
Single /Multiple Missing Number In Array
6:39
Просмотров 15 тыс.
5 Hacks to Get #hired at Intuit
37:52
Просмотров 8 тыс.