 What's up guys my name is Michael and welcome to my YouTube channel today We're gonna go do counting elements all right So you're given an integer array r and count the element x such that x plus 1 is also an r if they're duplicates count them separately So what you could do first is that you could actually remove all the duplicates in the array by putting them into a set and then Loop through the array again, and then check if for each element X x plus 1 check if x plus 1 is also in the array. So yeah, we already I already did that so I Could just type it up again. So So here I create a set no dupes. I'm gonna go through every single value value in my array So for auto val in array And I'm just gonna insert no dupes into Insert val into no dupes Okay, so that means now my Set is gonna have no duplicates right cuz set removes all the duplicates right after that All we have to do is just loop through it again, and then check if there's a count. So for auto Yeah for for every val inside r and then all we have to do is check if The value plus 1 is also in it so if val plus 1 so now how do I check if the val plus 1 is also in it I just have to do no dupes Dot count Right, so if it's also in it it'll you equal one right the count would equal one and if that's true. I'm gonna increase my number of elements to return so count elements to return I don't know I'm a Good variable names right count elements to return. I'm gonna add this plus plus and then after that I'll just return Count elements To return and yeah, so you made it and it got accepted So that's basically that's basically how you do it You would create a separate set to remove all the duplicates first because we don't want to count them twice right then after that You just loop through the array again and for every value check if the val plus 1 is also in in your set And if it is then we add it and then yeah, then after that See if it is in our set we got count is equal equal to 1 that means that means it's in our set Then we add the number of elements to return and then after that we just return So yeah, that's pretty much it on the next question is the middle of the link list and I already did that question So I'll just add that to the playlist. I don't feel like going over it again. So yeah, please rate com subscribe I'll check you guys later