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

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

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

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

    was looking for solution of missing and repeating number and this video gives the approach of that as well.

  • @shwetajha8745
    @shwetajha8745 3 ปีที่แล้ว +4

    I found this channel today. I absolutely loved your explanation.

  • @padarthiharibabu9412
    @padarthiharibabu9412 4 ปีที่แล้ว +6

    Thanks for introducing new weapon called xor.

  • @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.

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

    Was looking for solution of missing repeating number and this video gives the apporach as well.

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

    🥰 grt approach, another similar type ques is find one missing and one repeating number in array.

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

    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 😇😇

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

    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

  • @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.

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

    Thank you for this video, the explanation helped solidify my understanding of XOR.

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

    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.

  • @j-espresso
    @j-espresso 3 ปีที่แล้ว +1

    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

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

    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.

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

    The moment I saw the video I could recognize her from the Google Interview video she gave which was so good!

  • @RitikKumar-bk6pj
    @RitikKumar-bk6pj 2 ปีที่แล้ว

    Thank u mam nice explanation of this problem solution and again thank u for making this video..

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

    Keerti you nailed it. tremendous explanation!!!!!

  • @ShivamKumar-hi3pl
    @ShivamKumar-hi3pl 4 ปีที่แล้ว +2

    Please make more videos like this👌👌

  • @AceH-oe3nx
    @AceH-oe3nx 6 หลายเดือนก่อน

    Can we extend your solution for finding 3 missing numbers?

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

    Nice Explanation

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

    Nice explanation. I would not have thoughts of it

  • @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 ปีที่แล้ว +1

      Thanks, this is how we can really build the thinking process for interviews 😇

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

    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 ปีที่แล้ว +2

      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 ปีที่แล้ว +1

      @@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 🙂

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

    Nice explanations..

  • @ShivamKumar-hi3pl
    @ShivamKumar-hi3pl 4 ปีที่แล้ว +1

    Thanks for great explanation👍

  • @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.

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

    thanks for the upload

  • @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 ?

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

    Nice explanation.

  • @ANUJKUMAR-wc9dz
    @ANUJKUMAR-wc9dz 2 ปีที่แล้ว

    int arr[] = {2,3,4}; for this array how first approach is valid ?

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

    Thanks a lot , One of the best class

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

    you have done great work

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

    Learnt something new today

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

    great explaination thank you

  • @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

  • @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.

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

    Superb...

  • @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

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

    Thanku so much 💕

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

    but how code this in java

  • @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.

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

    the second method of finding two missing number is valid for unsorted array...???????????

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

    Video is really great. Please make tgese kind of videos so that it will be helpful.

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

      For sure. So many coming up!!😇

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

    It would be great if you create git

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

    Please please explain the code of XOR , I can't find its explanation anywhere on YT.

  • @dev-skills
    @dev-skills 9 หลายเดือนก่อน

    Watch with 1.5x and skip till 00:08:00 for the best solution.

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

    learned something new today

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

    amazing

  • @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.

  • @Deepak-gj4ni
    @Deepak-gj4ni 3 ปีที่แล้ว

    Here iam again 😂 in search of xor concept this time

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

    i still have a confusion how you calc N ?

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

    Why u dont show the code

  • @NeerajSharma-zs7xq
    @NeerajSharma-zs7xq 2 ปีที่แล้ว

    We are not looking for mathematical logic

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

    Keep it up

  • @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🤷🤷

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

    Nice explanation Keerti. I wouldn't have thought of XOR approach.

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

    theory toh de dete ho par code kaha hai

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

    XOR u beauty 🔥mast one mam❤️👍

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

    Code bta dimag to mene lga liya tha kese hoga ,code nhi aata 🤦🤦🤦

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

    i am your new subcriber mam or sister..

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

    Great video!

  • @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

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

    Book pad rhi ho ?

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

    Who the he*k marked this question easy on Leet Code?

  • @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

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

    Are you sindhi?

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

    damn she bad

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

    But mam, you started with finding 2 missing numbers. Please upload