Find missing number in an array(using summation and XOR operation)

preview_player
Показать описание
Find the missing number in the array which contains a series of consecutive numbers in range from 1 to n. Use summation formula for natural numbers 1 to n. We can also use the XOR operation.
Рекомендации по теме
Комментарии
Автор

This is great, thanks! Another advantage of XOR is that there no possibility of overflow, as there is with summation. (One very minor mistake is at 4:55 you wrote "0 XOR a = 0".)

LarryRuane
Автор

This is great video, exactly what i needed. Indian teachers are ❤️

abhijayrajvansh
Автор

always great and concise. thank you. I would like to see the algorithm implemented in c code.

naboulsikhalid
Автор

you are put the add right time by the way thanks for nice explanation

sanapalavenkatesh
Автор

Very clear.
I have a question, for your example case, could we just search from 1, to 2, to 3, until 5, when we look at 3, we know next one should be 4, and but it is actually 5; --- this assumes that array is sorted.
will XOR algo work even when array is not sorted?

lojian
Автор

Love you brother. You explained so nicely. Thank you so much.

PradeepSingh-vmgl
Автор

That makes a lot of sense. Thank you sir!

sakshimittal
Автор

In video at (4:56), in XOR table 0 ^ a = a, while explaining 0 ^ a = 0.
But I liked the explanation. It's too nicely explained.

skkark
Автор

How to find multiple missing number in array ?
like an array is= {4, 3, 5}
so the missing numbers is = {1, 6}

manishswarnakar
Автор

4:37 best way to understand XOR of n variables is that for odd number of ones(a in your case) the result is one(or a ) else it is 0.
If numbers are not sorted and duplicate entries are also there. How we can find the missing number in linear time and constant space ?

nasirfshah
Автор

Asymptotically both gives O(n)
But logically 2nd one will have to iterate 2 times.
So first one must be efficient, logically.

kirtivardhan
Автор

nice video! problem statement can be made a bit clearer: "find missing number in unsorted array", since for sorted array as in example input, it's too easy, if a[i+1] != a[i]+1 then return a[i]+1

Blingblingblingling
Автор

Thanks a lot sir.. You are doing a great job

tapanjeetroy
Автор

Thank you so much for making this video, awesome.

mustapharaimilawal
Автор

Sir,
I have a doubt how can i ask you❓️
Pls rply

ibrahimkhaleel
Автор

0 XOR a = a. U wrote it as 0 XOR a = 0 by mistake right?

adarshnair
Автор

Sir, can you provide how to find third largest element in an array logic

durgabhavani
Автор

Very clear, I am looking for implementation of algorithm using any programming language. Please help if possible, Thank you very much for good algorithm videos.

mangeshkumargabhane
Автор

sir, if you take 1 instead of ' a ' it is better for understand to us.

vickyjain
Автор

If we have scanner class then how to get sum of number.

indianmusicsongssaregama