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

  • @AmeyaKherodkar
    @AmeyaKherodkar4 ай бұрын

    One of the best videos for this problem and logic explanation. Kudos ✌

  • @nibeditadas4182
    @nibeditadas418212 күн бұрын

    Great explanation , need more such videos on different Leet code problems.

  • @AvinashSingh-tr5vt
    @AvinashSingh-tr5vt Жыл бұрын

    Thank you very much for the wonderful explanation 😊

  • @everyontech2716
    @everyontech2716 Жыл бұрын

    This is one of the best explained video for this problem

  • @zillboy
    @zillboy4 ай бұрын

    Amazing explanation, thanks 👍

  • @rachitkatariya
    @rachitkatariyaАй бұрын

    Bahut accha padhaye ho bhaiyaa aap.🫂❤

  • @ce132_sonugupta9
    @ce132_sonugupta93 ай бұрын

    xor solution explanation is nice🙃🙃

  • @vishnulavudya3160
    @vishnulavudya31602 ай бұрын

    the best explanation

  • @priyakoli5572
    @priyakoli55722 ай бұрын

    You explained so well then others

  • @walkwithAziz2024
    @walkwithAziz2024Ай бұрын

    Thanks excellent explanation Xor how use in this solution

  • @sarveshkuthe6283
    @sarveshkuthe62833 ай бұрын

    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 ?

  • @jjoelthomas
    @jjoelthomas5 ай бұрын

    Great explanation!!!

  • @sumitprasad4062
    @sumitprasad40623 ай бұрын

    Sir your explanation is awesome ♥♥♥

  • @anudey8496
    @anudey8496 Жыл бұрын

    like your solution! thanks

  • @businessmotivationspot
    @businessmotivationspot Жыл бұрын

    Hey man! your explanation skills are excellent.

  • @nikoo28

    @nikoo28

    Жыл бұрын

    Glad you like them!

  • @satyamgupta6030
    @satyamgupta6030 Жыл бұрын

    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

    @nikoo28

    Жыл бұрын

    So nice of you

  • @nobelcoding
    @nobelcoding2 күн бұрын

    Very nice explanations

  • @riya_1723
    @riya_17232 ай бұрын

    The best one 😊

  • @keshav9541
    @keshav95412 ай бұрын

    great bro

  • @gd24644
    @gd246442 ай бұрын

    thank you so much

  • @mikedelta658
    @mikedelta6586 ай бұрын

    Thank you.

  • @arundhuti4101
    @arundhuti41017 күн бұрын

    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!

  • @priyabratapadhi2421
    @priyabratapadhi2421Ай бұрын

    how this "xor " solution can't pass test case

  • @ghub1971
    @ghub19714 ай бұрын

    thank you sir

  • @souleymen971
    @souleymen97110 ай бұрын

    Thank you you help me so much

  • @nikoo28

    @nikoo28

    9 ай бұрын

    I'm so glad!

  • @HistoryHouse45
    @HistoryHouse45 Жыл бұрын

    sir can you make video on another part of this problem(repeat and missing number)

  • @nikoo28

    @nikoo28

    Жыл бұрын

    let me check it out.. :)

  • @Mosesdaniel77
    @Mosesdaniel773 күн бұрын

    🎉Good

  • @klyucherov.e
    @klyucherov.e9 ай бұрын

    Спасибо индусу за туториал 👍

  • @nikoo28

    @nikoo28

    9 ай бұрын

    you are welcome

  • @professormoriarty7439
    @professormoriarty7439 Жыл бұрын

    Is bit manipulation important for interview??

  • @nikoo28

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

  • @harikumarv5009
    @harikumarv50094 ай бұрын

    awsome brother🥸

  • @vamshisundupalle6141
    @vamshisundupalle6141 Жыл бұрын

    can u give the brute force solution pls

  • @nikoo28

    @nikoo28

    Жыл бұрын

    have you tried writing some code?

  • @vamshisundupalle6141

    @vamshisundupalle6141

    Жыл бұрын

    @@nikoo28 I tried but I can't got it

  • @kunalkheeva
    @kunalkheeva Жыл бұрын

    Hey Nikhil I love your content, do you have any plans for collabs? Like live problem solving and whatnots?

  • @nikoo28

    @nikoo28

    Жыл бұрын

    glad you liked my content. Yep...I have plans for collabs and live sessions when the time is right :)

  • @kunalkheeva

    @kunalkheeva

    Жыл бұрын

    @@nikoo28 or provide me your insta account I will dm you.

  • @nikoo28

    @nikoo28

    Жыл бұрын

    @@kunalkheeva you can email me on the address provided in the channel description :)

  • @chitra_13
    @chitra_137 ай бұрын

    0,1 ka kese niklega iss approch se

  • @nikoo28

    @nikoo28

    7 ай бұрын

    What do you mean?? Please elaborate a little

  • @abhasthakur36
    @abhasthakur363 ай бұрын

    Bruteforce ka code send krdo

  • @nikoo28

    @nikoo28

    2 ай бұрын

    You don’t need the code for brute force method

  • @demonders5486
    @demonders54866 ай бұрын

    😅😅😅😅😅😅😅

  • @jameshuddle4712
    @jameshuddle47124 ай бұрын

    Nice! The xor really capped it. Thank you! (I couldn't resist...) missing = arr.reduce((t,v,i) => t ^ v ^ i, arr.length);

  • @pavankumarpadamati8606
    @pavankumarpadamati86066 ай бұрын

    good explanation bro..

  • @user-yl4vp2ox8v
    @user-yl4vp2ox8vАй бұрын

    // 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(" "); } }

Келесі