 What's up guys Mike the coder here today? We're gonna go over the second problem of CSS problem set the missing number You're given all numbers from one to n except for one number. Your task is to find the missing number So your inputting is the array of all the numbers that you're given and then yeah Each number is distinct and it's between one and n and there's only one missing number that you need to find So how I did it was I actually did it by sorting and I don't think that's actually a good idea I found a better way to do it And I'm gonna code it up with you guys. Okay, so let's say so we're gonna read in the Array of Our numbers and then we're gonna just loop through and just read that in so let's do that for now And let me just change my thing Where's our Right on my array number array are our are right here. Oh Yeah, so yeah, by the way, I use LL means long long and we use that in competitive programming because that It's faster to type LL instead of long long, but anyway, okay, so let's let's get rid of this DFS real quick Okay, so we read in the number n and read in the number the array of numbers So how do we find the missing number? Okay? So what you could do is that you could actually just sum up all the values from 1 to n right using a math equation and then we just Loop we just sum up all the values in our array and then if we subtract that sum from that our sum We will get the missing number and the reason why is because of if you see this you're giving all the numbers from 1 to n Right, so if I do like 1 plus 2 plus 2 plus 4 3 plus 4 up to n right I add them all up up to n and then I subtract by my current sum of like all the rest of the numbers so the rest I Should get my missing number Right because I have the the total sum of all the numbers and I subtract from the rest of my Array values here. I should be able to get the missing number. So let's code that up So here we read in the end and we read in our array and then now we're just going to create a sum Zero and we're going to add up all the numbers. So let's do that Now so this is going to be the after we added up all our numbers and we're just going to do We're going to take total sum and What is the sum of all the numbers from 1 to n? so the sum of numbers from 1 to n is going to be a formula we could use so that's n times n plus 1 over 2 Okay Now after we have this total sum. We're just going to do see out Total sum minus sum and that should be your missing number and I believe this should work So let's actually submit this. I have to choose a file Okay Okay, I Believe this is this one. Yep, and it got accepted. So yeah, that's pretty much the gist of this problem I hope you guys understood what I was doing Essentially is I was just summing up all the numbers from 1 to n Using a math formula called this n times n plus 1 over 2 So that sums up all the numbers from 1 to n and then I just subtract from the rest of them And then I should get my missing number. So the rest of the numbers are the sum that we sum them up from our array of Values in here and then yeah, I should get the missing number. So yeah, but yeah So if you don't understand the problem, we have five two three one five and with the missing number here It would be four. Yeah, so yeah, so yeah, that's basically just of missing number and Yeah, what we guys are as video rate. I'll subscribe. I'll check you guys later. Peace