Missing Number (LeetCode 268) | Full solution with visuals and diagrams | Study Algorithms
Using some basic mathematics or a simple XOR operator can help you to arrive at an efficient solution to find the missing number. This problem is important from an interview POV, as it works as an entry gate towards bit manipulations. Understand the problem with the help of beautiful animations and visuals.
Actual problem on LeetCode: leetcode.com/problems/missing...
Chapters:
00:00 - Intro
00:53 - Problem Statement and Description
03:07 - Brute Force Solution
04:51 - Basic Mathematics is wonderful
07:17 - Using the XOR operator
12:59 - Dry-run of Code
14:42 - Final Thoughts
📚 Links to topics I talk about in the video:
LeetCode Problems: • Leetcode Solutions
Other easy problems: • Easy Problems
Brute Force Paradigms:
📘 A text based explanation is available at: studyalgorithms.com
Code on Github: github.com/nikoo28/java-solut...
Test-cases on Github: github.com/nikoo28/java-solut...
📖 Reference Books:
Starting Learn to Code: amzn.to/36pU0JO
Favorite book to understand algorithms: amzn.to/39w3YLS
Favorite book for data structures: amzn.to/3oAVBTk
Get started for interview preparation: amzn.to/39ysbkJ
🔗 To see more videos like this, you can show your support on: www.buymeacoffee.com/studyalg...
🎥 My Recording Gear:
Recording Light: amzn.to/3pAqh8O
Microphone: amzn.to/2MCX7qU
Recording Camera: amzn.to/3alg9Ky
Tablet to sketch and draw: amzn.to/3pM6Bi4
Surface Pen: amzn.to/3pv6tTs
Laptop to edit videos: amzn.to/2LYpMqn
💻 Get Social 💻
Follow on Facebook at: / studyalgos
Follow on Twitter at: / studyalgorithms
Follow on Tumblr at: / studyalgos
Subscribe to RSS feeds: studyalgorithms.com/feed/
Join fan mail: eepurl.com/g9Dadv
#leetcode #programming #interview
Пікірлер: 51
One of the best videos for this problem and logic explanation. Kudos ✌
Great explanation , need more such videos on different Leet code problems.
Thank you very much for the wonderful explanation 😊
This is one of the best explained video for this problem
Amazing explanation, thanks 👍
Bahut accha padhaye ho bhaiyaa aap.🫂❤
xor solution explanation is nice🙃🙃
the best explanation
You explained so well then others
Thanks excellent explanation Xor how use in this solution
What if we use the freq array approach and find max element in array and create the freq array of that size and then increase the index, we can check if the index is 0 then that’s the missing number ?
Great explanation!!!
Sir your explanation is awesome ♥♥♥
like your solution! thanks
Hey man! your explanation skills are excellent.
@nikoo28
Жыл бұрын
Glad you like them!
what an excellent explaination bhaiya . Thanks for making such amazing videos for we student. I always look for ur videos whenver I search a problem on yt.
@nikoo28
Жыл бұрын
So nice of you
Very nice explanations
The best one 😊
great bro
thank you so much
Thank you.
If we add all the nums in the range and then also add the nums in the given array and subtract the sums. we would get the required answer. Wouldn't this be the most efficient way for a brute force method? btw wonderful explanation, thanks!
how this "xor " solution can't pass test case
thank you sir
Thank you you help me so much
@nikoo28
9 ай бұрын
I'm so glad!
sir can you make video on another part of this problem(repeat and missing number)
@nikoo28
Жыл бұрын
let me check it out.. :)
🎉Good
Спасибо индусу за туториал 👍
@nikoo28
9 ай бұрын
you are welcome
Is bit manipulation important for interview??
@nikoo28
Жыл бұрын
to be honest, it is very unlikely that you will get tough bit manipulation questions during an interview. You are just expected to know the basics, like what is left shift, what is right shift, XOR etc. As an interviewer, I would never ask a programming problem whose solution relies on a bit manipulation technique.
awsome brother🥸
can u give the brute force solution pls
@nikoo28
Жыл бұрын
have you tried writing some code?
@vamshisundupalle6141
Жыл бұрын
@@nikoo28 I tried but I can't got it
Hey Nikhil I love your content, do you have any plans for collabs? Like live problem solving and whatnots?
@nikoo28
Жыл бұрын
glad you liked my content. Yep...I have plans for collabs and live sessions when the time is right :)
@kunalkheeva
Жыл бұрын
@@nikoo28 or provide me your insta account I will dm you.
@nikoo28
Жыл бұрын
@@kunalkheeva you can email me on the address provided in the channel description :)
0,1 ka kese niklega iss approch se
@nikoo28
7 ай бұрын
What do you mean?? Please elaborate a little
Bruteforce ka code send krdo
@nikoo28
2 ай бұрын
You don’t need the code for brute force method
😅😅😅😅😅😅😅
Nice! The xor really capped it. Thank you! (I couldn't resist...) missing = arr.reduce((t,v,i) => t ^ v ^ i, arr.length);
good explanation bro..
// Online C compiler to run C program online #include int main() { int arr[] = { 1,5, 9, 100 }; int m = 0; int size = sizeof(arr)/sizeof(int); for (int i = 0 ; i { for (int j = m+2 ; j { if ( arr[i] != arr[j]) { printf(" %d", j); } m = j ; } printf(" "); } }