 What's up guys my name is Michael and welcome to my YouTube channel today. We are going to up solve round code forces 671 I know it's kind of strange that I haven't been uploading at this time, but Yeah, I have not been uploading at all recently Mainly cuz like I haven't live streaming at all I'm trying to like fix my sleep schedule and having really bad problems like waking up early because of this whole coronavirus thing All the classes are online stuff like that, but yeah Right now we're back Yeah, I normally don't live stream at 5 p.m. It's probably way early for you guys probably super duper early I don't know. I don't know what how early it is for you guys. Let's see. What time is it in India right now? I want to see what time. Oh, it is 2 30 a.m. For you guys Wow, this is a terrible time to be live streaming for you guys, but anyway, I need to So I didn't I did pretty bad this round code forces 671 the reason why is because I just woke up super duper early and I could not actually solve these problems because I was just super duper tired. Okay, but Now we have the editorial so I'm gonna up solve this so I'm going to up solve the this problem And then we'll see how to do it. So basically you have Yeah, they want to play team matches of a game So the problem is this yeah, there's team matches of a game raise and breach want to play These matches of a game in each t-digit matches of the game a positive integers generator It consists of n digits So it contains n digits the digits of this integer are Numerated from 1 to n from the highest order digit to the lowest order digit after this integer is announced the match starts Agents plays and turns you start in one turn you could choose an unmarked digit and market raises can choose digits on odd positions, but Can't choose digits on even positions breach can choose digits on even positions, but can't choose digits on odd positions So when the match ends when there's only one unmarked digit left if the single last digit is odd then raise rings Otherwise breach wins, okay? So I could not solve this problem. I actually thought that So originally I thought that if you were to Just Let me just get my pen real quick and show you guys what my original thought process was and it actually did not work And I'll see the editorial and see how they actually just did it, but yeah, I Tried many different things to try to solve this problem Yeah, I tried Tried sorting I did a lot of other things, but I'll explain my thought process and what I thought about doing this problem Why it did not work and then I'll both try to implement their solution. All right, so first let me get the Tablet to write this on Whoops My bad my bad guys So, yeah, let's let's do this Yeah Okay, so Yeah, okay, so let's let's just write this down and This is draw these problems out and then see what I did wrong and why it didn't work So my thought process was because we have our Raise and then we have breach right and our can only remove odd positions and Breach can only remove even positions Right, so these are the two Even positions so these are the two these are the two people that are playing this game Right and we have Even positions odd positions right we have a number named has n digits Yeah, no, we have a digit name and there's just number of digits. Yeah, so we have a number n contains some amount of digits, let's say It contains n digits So they want to remove each digit ability to make a turn In the end if there is a If the last digit is odd then raise one wins otherwise breach wins, right, so we're gonna remove a digit One digit from each of these right, so let's say I have one two one oh two right, so the number digits is three Right, these are number digits in this number and if I were to remove all the odd digits and raise begins first Right are begins first raise raise begins first, right? He begins first So and they're numbered from one two and three so if raises begins first Let's say he removes the last digit because this is an odd position so he moves this to then B goes B goes he could only remove an even position so B goes removes this even position which is to so he removes this zero and then we have one which is an odd number and That's left. So that's why 302 gives you one Okay, so one is an odd number that's left. So 302 this one oh two right three one oh two gives you raise wins raise wins Raise wins because last digit is odd. So raise wins if If last digit is odd otherwise Breach wins Right, so that's basically the gist of this problem So originally what I thought was I thought you could just go through If you're gonna keep removing odd goes first, right if our goes first on We should know what I thought is if If our always goes first, right and he only removes the odd digit. Well, if you're gonna remove The odd digit first and then even then odd and even Given if we have an odd number of digits Your last number is just going to be this number, right? The first digit and if that's odd then you can just check if that's odd if that's odd Then raise wins otherwise a breach wins, right? And I also thought that if you had like an even number of digits, so let's say you had Let's say you had a two zero six nine Right, so there's four digits here, right? there's even number digits four zero four four digits here and Our goes first and then B goes first So if our goes first he's gonna remove the three If B goes first he's gonna remove the Add position force there's nine If B goes second he goes over the nine then if our goes first he's gonna move position one then if then B goes So then the last digit is Gonna be a position two So then you would have even it'll just be even, right? So if you keep doing this over and over again, I always thought that If you keep removing it You're gonna end up with at the second position Right the second position if the number of digits are even you're at the second position you would have You just have to check if this is odd or even right you will in the end You'll just be at the second position So you just check if it's odd even and that actually did not work So let's actually look at the tutorial Editorial and why the editorial says that this doesn't work So they're saying is that let's say that digits on odd positions are blue and digits on even positions are red Right, so there what they're saying is that? Now love to let's say you have two zero six nine right and then we have one two three four So we're gonna label all the ones odd at with an R and then even out with a B, right? So we're gonna have R be R be okay now if N is even the remaining digit will be red Okay, so if N is even the remaining digit will be red Yeah, so if N is even Your main blue red if N is even the remaining digit will be red How's that so? Why would the remaining digit be red? Wait two zero six nine let's look at two zero six nine Um Your remaining digit will be red. Why would it be red? So if you cut if you remove three and then remove four Move one your main digit should be blue, right? Hold up if N is even the remaining digit will be red if there is at least one Even red digit then breach wins Mark all digits except the one that will remain in the end In other case raise wins because any digit that may remain is odd if N is odd The remaining digit will be blue If there's at least one odd digit then raise wins Oh wait, they're saying oh Wait, they're saying okay. My bad my fault my fault guys. Okay, so they're saying is that let's label them the opposite colors So they're saying R be right. They are saying that let's label the digits on odd positions are blue and digits on even are red So odd positions are blue Even are red This is kind of opposite with what the actual problem statement said because the problem statement said our R can only We'll choose an odd position but can't not choose even positions to remove. This is kind of opposite. Okay Now if N is even the remaining digit will be red If N is even The remaining digit will be red three Then four so we're number three remove an odd position. They're not even position in an odd. Yeah, the remaining position will be red now if If there is at least one Even red digit then breach wins If there is at least one even red digit At least one even. Okay, so this digit is even red digit, so That means breach wins Okay, so then B wins. Okay So I'm guessing the reason why the label that blue red blue red is because that's gonna be the next person's turn, right? So if if red removes Three right Then it's gonna be Blues turn Right, it'll be blues turn. So if we're gonna Say the digits are say the digits on opposition are blue and digits on even positions are red And as even the remaining digit will be red if there's at least one even red digit then breach wins You can mark all digits except the one that will remain in the end so There's at least one even red digit You can mark all digits except the one that will remain in the end. So That's all even digits You can mark all red digits in the last one There's at least one even Red digit then breach wins you can mark all digits except the one that will remain in the end So One even digit you can mark all red digits besides the one Mark all digits except the one that will remain in the end. So breach wins. So breach would win if the Last digit is even remember breach wins if last digit is even Red ones when the last digit is odd right okay, so if if In other case raise ones Because any digit that may remain is odd Okay, so if there's at least one even digit then breach wins We can mark all digits except the one that will remain in the end If there's at least one even red digit breach wins. Yes In other case raise wins because any digit that will remain is odd So if there was an odd digit here, so maybe it's like One three five seven right and then we have one two three four and we mark all these BRBR and Then we remove three four one In the end we have to check if this is the Odd right so if this is odd then If it's odd then Raise ones. Yeah, raise would win. Okay. If n is odd the remaining digit will be blue If there's at least one blue odd digit then raise wins use the same strategy apply her hmm Why do we label them blue blue? In the exact opposite positions, so that's a big question Hmm, let's see. Yeah, probably was very very difficult for me Yeah Size of numbers not given so you cannot store using it You cannot store you to try using a string input number a I don't know what that means Okay, um Yeah, okay, so let's just code this up now Let's do this, okay So I'm trying to make sense of this editorial But I don't get as much to the odd and even positions with the red and blue Maybe I'll ask that question because I feel this is kind of strange for a problem a why did you switch be to be Odd positions and are to be even position Isn't it? Isn't that the opposite the problem statement? Did I just lose my internet connection? You guys hear me? Okay, and you guys hear me? Not sure Anyone in the chat? No one's in the chat. It's okay guys. Okay very strange Okay, um, let's just Let's just code this up. Okay, so So we have n and s and then now we need to check we have to label the ones with RB BR BR BR So we're gonna do like another string Let's call it X And we do for I equals zero I is less than n I plus plus Let's do like a long long Yep, and then what we're gonna do is we're gonna do if I is Mod to is equal to zero then we're gonna do X plus equal to plus equal to a B otherwise do X plus equal to a and We need to do this. I think it's like this. I don't know if I Don't remember what the position was but we'll check that later. Um, yeah So it's B and then a B a B a B a So now we need to check if there's at least one even red digit then breach wins So if we're gonna go through Go through the Let's go through here again Okay, and then we're gonna go through here and then we're gonna do We're gonna go through here We're gonna go through here and then Yeah, so if it's even there's at least one even red digit then breach wins So if n is odd, okay, so we're gonna check if n is odd and one red then breach wins so if if s at I Str at I is odd let's Change it to Casual to a digit By subtracting it to its numerical value if it's odd Then what we're going to do is we are going to At least one red digit that's odd We're gonna we're gonna subtract it. Yeah, so we're gonna check if there is at least one Oh, if there's at least one even red digit then breach wins so if there's even red digits And x at I Minus zero even then Breach wins so we just do see out Two two wins and then we turn Break see how two wins Actually, we should have One wins equal to true We should just say one wins equal to false and break One wins false break break All right Okay, this is assuming that if n is even the remaining digit will be red If there's at least one red digit then breach wins. Okay, so if n is even So this one you have to check n mod 2 is even Then we do this Right even One wins is equal false break. Then we just have to do if one wins Then see out one Otherwise see out To okay Otherwise we have to check In the other case raise wins because the digit may remain beyond And as odd there remaining digit will be blue if there's at least one odd blue digit then raise ones Okay, so let's see blue raise ones. Okay, so Raise wins equal to true Then we have to check if there is a at least one odd digit so if For I equals That's an N I plus plus if SI subtract by zero Mod 2 is equal to zero STR Equal equal to zero Then raise wins so then raise Equal to Blue there's at least one odd digit then raise wins. Okay, so otherwise, so this is actually supposed to be breach wins breach wins It's true breach wins equal to false Break So there's at least one even digit And raise wins So this is actually not odd digit And it has to be blue. So we have to do and STR at I Is equal to a blue? Yep. Okay. Now if breach wins Then see out one Now see how to otherwise see at one. Yeah, okay Ideally this should work Let's just go down here Let's see, let's see what we're gonna do. Okay, so we have three four one two Let's see we have four one Two, let's see if how many should be yep, that's true Print out two which is right Okay, so let's look at another one. Let's actually look at something larger like four four two oh six nine four two oh six nine So add B at a at B at a Okay So two wins. Is that the same right? That's right. Okay. All right now Let's actually just submit this and see what where this takes us and We'll be on array Wrong answer on one. What is the problem? two two two two One should give us three One three should give us one. Let's see one three should give us one. Oh, what the? As to your I did that it's something stupid here. This should be a X No, what is X should be an a X should be equal to an a Which is a like that Yeah, and now what is the problem? Okay, now we're gonna try it again Okay, um, let's see So wrong. Okay. What is the problem now? To do to do. Okay, so we still have a problem with the beginning one Let's just see what that is One three should give us one. So if there's Then as even the remaining digit will be red if there is at least one even red digit then Breach wins. Ah, this is what you should be are Whoops. All right guys. Now it should work. Now it should work should work now okay, and And Still wrong. What is the problem? Okay, um, let's see one three We should have one and then three So let's see of the code. What is the problem? Okay, so if we have four one two one three so if we do four and then one three B I Said a it should be are Maybe that won't work actually let's see Still wrong. Okay. What is the problem? Why is it? Why is it? Should be X My fault. I'm making so many careless mistakes so many careless mistakes And now we are going to check this see if this did this work Yeah, I got a seed. All right a big question is why did they switch the two? So the digits on odd position blue if and is even the ready remaining red digit will be red If there's at least one even red digit then breach was wins Hmm Even red digit I'm guessing cuz like when you remove something it's the other person's turn Right, so if we have like like if we have two two oh six nine, right? So I'm gonna explain why they do this way so like if we have two oh six nine one two three four So remember R can only remove odds odd positions B can only remove even So if we label this instead of doing label it the opposite direction, so the label this as B R B R right So when you remove an odd position we're going to raise raise starts when our starts This is going to get removed right three is going to get removed. So then the next position That Um Can remove is going to be even So does this become two oh nine? Think two oh nine. Let's say one two three and then you remove an even position Well, that doesn't make any sense Maybe it has to do it. Yeah, I think it has just has to do with the next position Because if you remove if our our starts first who removes this next You could possibly remove is Hmm, I'm not sure why they they labeled it the opposite positions Rb br br We're gonna have we're gonna have to think about that I'm gonna have to think about that. Um, let's see no one's in the chat right now. So it's okay It's okay guys. It's okay It is fine that we are only watching ourselves. Okay But anyway, let's look at the next problem, which I did not get to solve and We'll try to solve that and Yeah So we have staircases Um She wants to go as high as possible if the staircases and stairs and it is made of n columns the first column is one cell the second It's two there ones n so summation from one two three up to n Right That'll be the number of cells are in here Yeah, though, that would be a number of cells in one two three four. Yeah, um So their case n is called nice if it can be covered by n disjoint squares made of cells n disjoint squares made of cells All squares should fully consist of cells of a staircase Huh, excuse me We also have to do an at-coder tomorrow There's an at-coder contest tomorrow Got to keep doing these contests got to keep up solving Others are not gonna improve Did I register for this? Did oh, yeah, I already registered for it ACL contest one. Um, yeah Yep. Okay. Um Yeah, if the staircases n stairs then it's made in columns. Okay Staircase with n stairs is called nice if it may be covered by n disjoint squares made of cells So in this case One two three four five six seven eight nine ten eleven twelve thirteen forty fifty seven eighteen nineteen twenty two one two three two four five Twenty-six twenty-nine thirty three one thirty two thirty two Thirty two is divisible by is Nice because it could be covered by n disjoint squares made of cells So one two three four five six seven Huh Okay, so if you were to Find the large largest possible square you could make Here which is like four square Right five squares would be too much Yeah, five squares would be too much five square because we have one two three four five six seven eight nine ten eleven twelve thirty fourteen One two three four five six seven eight nine ten Eight nine ten eleven twelve thirty forty seven eighty nine twenty one twenty two thirty four two five six seven eight nine ten eleven twelve thirty fifteen sixteen seventeen eighteen twenty twenty one twenty two Wait, hold up. Let's summation from one to seven one two three four Yeah, let's see summation one plus two plus three plus four plus five Six plus seven twenty eight. Okay, so twenty eight is divisible by seven, right? four one two three four One two three four five six wait one two three four five six seven, okay Yeah Four and yeah, okay, so there's twenty eight squares The maximum you could do is four so then There's twenty eight squares Four thirty two, so I think it has to do with the multiples of two right So the reason why they can't do it with five squares because that's gonna be like in a draw like a So let's say we have here Five squares one two three four five it can't be five square right because This would be too much. It will get past here. So I think it is a multiple of two So the highest square we could do is a Two to the fourth right because there's third twenty eight squares Keep in mind guys. I don't know actually I don't actually know the solution. So there's twenty eight squares, right? and this is just the summation of one plus two plus three up to Seven right and this is n equals seven. So there's twenty eight squares and we want to find the Squares that consists of Destroying squares right the largest square is Is two largest squares do so Yeah, it will be 16 2 to the fourth is equal to 16, which is less than 28. I don't know why why is it drawing diagonally? It's very strange. Okay. Yeah, and two to the fifth is 32 Whoa, sorry guys to the fifth is 32 and this is greater than 28. So we can't do that So I'm guessing it has to do with powers of two Yeah, and then um if you were to keep subtracting by powers of two Right. So like if I do So remember we have 16. We have 28 squares, right? If I subtract two to the Two to the fourth from 16 Right, so 28 is going to equal to two to the fourth plus two to the One times to the fourth to a third to the second to the first So 28 minus 16 would get me 12 so that means I could use two of Can't use an eight. I Can use an eight. Yeah, so I could use an eight because I have one two three four five six seven eight Yeah, so there's eight of those so I could use a One eight and then there's zero fours I Can't use those and then I have a certain number of twos One two three four, I think it would be So be 16 plus eight plus Four, oh, well, yeah 16 plus eight Four you could use one of these you could use one of one four and then you have zero twos Okay, so in the end we're gonna have one one one zero one zero, okay So I'm guessing it has to do with something with powers of two Right because that's how we get the answer here, right? Now the big question is How do we get to seven? Make sure there's seven of these so we need to make sure there's seven of one two three four five six seven So I'm guessing it might have to be the coefficients of here one plus one Plus one would be three Well, excuse me eight but like See that that's that's a big problem is like if you I mean if you could beat I Have no idea. I don't know what I'm doing Find the maximum of different staircases. They can be about using no more than X cells hmm, I think it has to do with like I'm not sure actually not sure like if we if we use Hmm this has to be seven of those right so we have 28 Must be seven of these So we have 16 which is one one giant block. We have two fours and Then we have four ones. So we have Two fours. So let's actually not use an eight. So let's let's clear this out again So I have 28 and then we have We have 28 and then we have a few few of these so Hi. Hi, Omar How you doing in the chat? The first view I got Yay Look normally. I'm just talking to myself It is amazing Have you solved this problem before? Okay, I'm just gonna guess. That's a yes. Okay. All right. So we have 28 and then we have What I'm trying to do if you're new to this chat what I'm trying to do is I'm trying to split these problems these these Blocks into perfect squares of twos Right. So we've right now. There's 28 squares, right? And the reason why it's good is because We could have seven Disjoint score perfect squares, right? So like so here we have like this one giant perfect square So that's one and then we have two of these fours, right? And then we have One two three four four for these ones. So what I'm doing is I'm just Splitting it off by like numbers of perfect squares. So we have one block of 16 right a block of 16 four by four then we have Two blocks of two by two. So we need to add that. So two blocks of two by two and Now we need to add Four blocks of ones so four blocks of ones four blocks of ones Okay, and then if you were to check these coefficients out One plus two plus four you should get seven and that's the same answer as N Okay All right, so So So I'm going to attempt to code this up Um Yeah, so we're gonna try to find the first largest number which is We got to do log base of the summation of one to N and then log base of two of that so that'll give me This number of 16 right then I'm going to subtract One off of that and then I'm gonna subtract two to second and then two to the first is two to zero Okay, and then each time I do that. I'm going to add it to a constant For each coefficient so one two and four and then if the end constant gets me to my original end And the equals seven then it's right. So I'm gonna do this mathematically Okay, guys Maybe I should have done this problem first before you go into the We're doing the second one. I don't know. Do you guys get problems? I'm not sure Yeah, I'm gonna do a series on Cracking the coding around for Google. Did I I don't think I ever went over any Google coding rounds, but yeah, thanks I'm glad I helped you though any I mean Sheesh It's how you pronounce your name machine Hi true nationalists Are you a real nationalist? How true are you? Where you guys from by the way? Yeah Good job for cracking the coding round for Google. I don't I don't know how I don't think I ever went over any Google problems Maybe there was one. I don't know. I have no idea But yeah, congrats on cracking that But yeah, let's go back to this problem let's Okay, so what we're gonna do is that we are going to take the log base of Let's see contains an integer x The number of cells buildings Maximum of difference nice staircases. Oh Crab we have to find the maximum number of different nice staircases We can't just determine whether n is a nice staircase or not. Oh That is difficult in that case. I actually have no idea See how the tiny change of problem changes the whole problem completely maximum on different nice staircases No more than nx cells You see I only could figure out like one nice staircase, but yeah, I'm out of luck I think I'm just gonna go to the editorial All right, let's see Let's prove that the minimum number of squares needed to cover the staircase staircase is not less than n Why wouldn't it be less than n? n is the height of the staircase To the highest cell of the staircase is the top left cell of some square. Um, yes Sure. Yes Like one The top left one did this top left to is going to be a square The top left of this is going to be a square also Maximum top left. This is a large square top left of this Is going to be this square Top left of this is going to be the square top of this is one square Okay, um So let's consider a square that covers Wait to the highest level is the top left of the square. That's why we need at least n squares Well, I thought we're talking about x No, we're different staircases for x though. Okay, whatever. Um, that's why we need at least n squares Okay. Yeah You need you need exactly n squares if and only if the top left of each stair case is a top left cell of some square Let's consider a square that covers the lowest cell in the last stair Okay, so like this lowest cell last stair or do they mean this What do they mean by this could be this one or that one Okay, I'm gonna assume the bottom left Um, it's top left corner should contain the highest cell with index and plus one over two for odd The top left corner should contain the highest cell with n plus one over two for So there's seven Plus one is eight over two. It is four. Okay. Oh, okay. So that could if it gives us this Okay, um, I was gonna just sum it up and then do log base or two, but I think that works I don't know where he got this from for an odd n Then the staircase is a divisible divided by two staircases each of n minus one for two stairs height uh-huh n minus one over two stairs of height so Each of which Okay, so seven minus one is six over two which is three So, yeah, you should these have a height of three These staircases should be nice too. It means the nice staircases are two to the k minus one stair is high Yes, I believe that is so I said it was a power of two where k is greater than equal to one um Two to the k minus one series. So if it's like four three seven three seven four sixteen fifteen five Okay, so they're saying that the top they're basically making a math statement saying that All stairs are nice if there are the number of stairs is two to k minus one Because then you're able to split it by a power of two. That's what they're saying Okay, um to maximize the number of different staircase which it creates the staircase really okay So this is what I was trying to figure out If that is even then consider a square that had the lowest cell of last stair Ben is even then we can can consider a square that will have the lowest cell of the last stair Lowest cell of the last stair What does that mean? Lowest cell of the last stair The top left corner of the square may not contain any top left cells of the staircase And that's why you will need more than n squares. This means that a staircase with an even height may not be nice Even height may not be nice Let's get back to this. Um, let's see Okay, thanks Um, thanks I'm glad I helped you Let's see, uh Okay, so the even heights I kind of want to recreate another series of c++ because I I didn't really I didn't really teach you guys that well But yeah There's definitely I could have definitely taught way better. Honestly I'm not gonna lie. Um Anyway, if n is even then we can consider a square that have the lowest cell of the staircase The top left cell of the square may not contain any top cells of a staircase That's why you need more than n squares. This means that a staircase with an even height may not be nice We create staircases greedily if n is even then we consider a square the case that have the lowest cell of the last stair I don't understand killed ray joy Holy crap, this is insane Look at these These problems are difficult difficult One day. I will be able to solve up to e and f one day Mark my words guys mark my words. I will be able to solve up to e and f one day In two years, I'm gonna maybe not two years maybe three or four I'm gonna come back to this video and I don't really like wow How come you weren't able to solve these? One day guys one day Okay, um Let's go back to this I don't understand Because if we're gonna This solution didn't Jury solution pay spin Um What what is he doing two to the i minus one? Oh, okay. I get I get what you're doing I got what they're doing. They're basically you know what I was doing You select the maximum power Oh, excuse me greedily select the ones that Are powers of two So this is the powers of two minus one is going to be the To the n minus one is going to represent the um to the k minus one is the number If not, if the staircase is nice, right? So they're going through all nice staircases while it's less than you go to x Each time they're doing that they're subtracting the number of nice staircases. Um get s is the the Total number of n So that's the summation of one to um x n times n plus one over two. I think Let's see summation of one to n Yeah, okay. Yeah, okay. So I I understand what they're doing. Okay, so here We could actually do this ourselves. We don't actually have to look at the editorial. Yeah, okay. Um, so look We have x right? We're gonna loop from one zero to x Actually one to x um During this time of one to x we need to get the the number of um The number of good ones good values, right? So that's While the number of good values, we're going to go through all the good good squares So all the powers of two that are good squares. So the good squares they said is because Anything that are two to the k minus one stairs and high high Right, and that's because if you were to cut the highest power you're gonna have These two squares left, right? so that's why the The number of squares Of this is going to always going to be One less than the highest power of a two Right, so if we're going to go through each of these and get the um some of all the numbers We could subtract the ones that are not good and they'll get and then count up the ones No, we subtract the num the number of squares that are good And keep a count of how many there are left And then that'll be the answer So, uh, maybe i'll have an explanation video explain that what had just happened to my computer Sorry guys. Something just froze on my computer Okay, can you still see? I hope you guys can still see Yeah, okay, so yeah So we have to get so there's So we're going to go through all the good We need to get all of the We need to sum up all the numbers of So, okay, so what we're going to do is we're going to loop from one to x One to x is just going to be All the different ways that we could sum up the numbers, right? One to x because we need to count the number of different Nice different nice Nice squares, right? Nice squares, right? So we need to count a sum This sum is going to if I give you a value of x is just going to return The total sum which is x times x plus one over two right this represents This represents The summation of all the the values of the highest staircase So when i'm summing in this case, it would be the sum of one to seven And that would give us n plus n plus one in times n plus one over two, right? So here we're gonna We're actually going to keep looping through until our while our sum of i Is less than or equal to x, okay, and during this meantime we're actually going to multiply a current number by The power of two so we're going to have a answer Answer is just going to increase every time By one answer is going to increase every time by one and While this is a case. We are going to take A power of two, right? We need to Subtract some by a power of two. Is that what they did? Yeah, yeah So they're going to subtract x by The power of two to k minus one, okay. I'm going to give a more in-depth explanation of this K represents i Yeah, yeah, okay, so I'll give a more in-depth explanation For now, uh I think this this would just work Okay, I understand the other tutorial though, so I'll give a I'll give an explanation video for both of these problems But in the meantime, I hope you guys enjoyed this. Uh, let's me just submit this and then I'll be on my way Wrong answer. All right. What's the problem? 59 59, um, two to the Two to the k minus one. That's right. That is what is right there Minus equal. Oh, we need to get some of two k My bad It's some Of this Okay Okay, all right. Uh, I understand what were the logic of what they're doing So I'll give an explanation video in the meantime Like if I try to explain right now, it's pretty difficult to Uh explain but yeah Timeline exceeded for test one. What? What's the problem? infinity, um Two to the i minus one That is right pow some Uh x one ah I didn't use long long My fault, um It should be long long Um Yeah Two to the i minus one Should be right Um, let's see Yeah What is it done with this? Return zero. Yeah, this should be right Hold up hold up Unless they don't use fast power Wrong answer on one That doesn't make any sense This is right though to the i minus one Shifting left is what what that is Shifting left is multiplying by two, right? Is that raising it to a power of two? Yeah, um I don't know i is one i plus plus To the i minus one Ah Ah This Okay, now it should work Okay, um, I'm gonna explain the solution later and uh, yeah, we'll be on our way I'm also going to give a lecture video on, um, stable stable marriage problem, which is an algorithm and I'll go over that Because I'm taking algorithms class and I like to explain that to you guys also But yeah, I'm gonna explain a and b in in later two videos and maybe I'll go over c But yeah, uh rate com subscribe. I hope you guys enjoy this live stream. I'll