 What's up guys my name is Michael and welcome to my YouTube channel today We are going to go over code forces round 667 a yet another to integer problem Okay, so basically you're given two integers a and b and you have to choose a number k To add to a you want to get you a to b, right? So you have a number two numbers a and b and you want to get a to b and basically all you what you do is um You could do make a move to make a move You just add a number number k, which is between 1 to 10, right? And you could use different values of k in different moves So now our job is to find the minimum number of moves it takes to get from a to b Okay, so I hope that I I basically Summed that up pretty nicely Well, I'll try to try to explain again We have a number a so I'll use this basic test case and the problem 13 13 there's a number a right and we have a number b is in 42 we want to get a to b In the minimum number of moves So you so a move we could do is that we have to add a number k from 1 to 10 so one move We could do is So one move is basically adding a number of k and this k is between 1 to 10 Okay, this k is an element of 1 to 10. Okay. This symbol is just an element symbol But this k you could add a k or you could subtract a k that's an element of 1 to 10. Okay Okay So that's that's what you could do In our job is to find the minimum number of moves it takes To get from a to b. So um, basically what I did was I just if you want if you want to think about this You have to think about the minimum number of moves it takes right So first what I did was I looked at b first And I realized if I want to get from a to b I have to subtract Right because there's a certain number of values that would take to get from a to b So what I did with first was I just subtract 42 minus 13 and that gets me 29. Okay, so this would be like the difference between both of these 42 minus 13 the difference between both of these right so if you're going to um There's a certain number of moves you have to make to get your difference to 20 29 right to get from a to b So now because we what you want to find the minimum number of moves it takes You have to think about minimizing the number of moves Well now think about this if you want to minimize the number of moves What should you do? For each move if I can only add a number K from 1 to 10 Right I want to minimize the number of moves it takes So what does that mean? I should maximize The amount of K I'm going to add Do you guys understand what I'm saying? I need a maximize number of K I'm going to add So then the number of times I'm adding K is going to be minimum as possible Right, so if I'm going to minimize the number of moves it takes I have to look at the maximum value of K I could add and that's this 10 Okay That's this 10 So what should I do here at this point? I should take 29 Our difference of 29 and mod it by 10 The maximum K that I could use which is 10 and that will get me to Um 29 mod by 10 here Is going to get me 9 right? Okay, so that's the that's the the remainder when you mod by 10 it would get you 9 Right, so that what are the number of times I could do For the moves I would take Right the moves it would take to get from 29 Uh the moves it would take for each move Well, it would take two moves Right Two moves to get me to a remainder of 9 To get me close to 42 Right because if I use do two moves I add by 10 each time I'm going to get 13 plus two Plus 10 plus 10 right two moves and that's going to get me to uh 33 Right, but then I have a leftover of nine remainder of nine Here right, so if if I need to so if if I get have this case Where I'm adding by 10 Every time right use a maximum number of times it takes I need to If I have a remainder I need to add another move Okay, so if I if I do a move of 10 10 10 the next move it would take should be another 10 Right, so this would be should be should should take three moves So then I could uh this would get me past 42 so this would get me 43 So the minimum number moves it would take would actually be three Right if I have a remainder at this point, right Do you guys understand what I'm saying? So if if I'm going to do a certain number moves every time Right, I want to minimize number moves. I need to make sure each move is maximum as possible Okay, so if I'm making each move maximum as possible I'm taking the difference modding by the maximum number it would take to make a move in this case 10 And that will get me the difference. It would take the remainder If this remainder exists I need to have another move So I add another move to my ending result. So that's basically how you do this problem What I did here was I took the difference I'll look at I'll show you guys the code what I did I took the difference between a and b right assuming the larger value is a Right We take the larger value and we take the difference between both of them Right the difference We mod by 10 the reason why we mod by 10 is 10 is the largest possible number that we could do for each move Okay, so once we mod by 10 We check does this equal to zero right because if it if it's doesn't equal to zero Which means we have a remainder here. We need to add another move We need to take another move of 10 for our result. So we add by one So that's what I did here. I took a minus b divided by 10 add by one and that will get you The result there otherwise you should just divided by 10 that would be the number of moves It would take for you Okay, because that would be like let's say was like 40 or something and you or 20 It takes two moves, right? And it actually took two moves and then it didn't take you anything at all here There would be no remainder then you just leave it out, right? You just have two moves at that point. So yeah, that's basically how you do this problem You need to basically to figure out this problem. You just have to find out Difference between a and b The number moves right here and then you you mod by the maximum possible value for each move In this case would be 10 and then yeah, and then if it doesn't equal to zero You add one to the end result if it does then you just do nothing, right? You just it would just you just divide by 10 here. So that that's basically what I did for this this problem So also to get rid of the negatives any negatives that it could occur I swapped a and b whichever is the larger one. So the larger one's on the first And yes, so on for so forth. So then there's no like negative values, right? So that would because each move you could have positive or negative Each move you could add k or subtract k. So the difference really doesn't matter that much, right? To avoid all the negatives jargon because we only care about the number moves All right, so that's basically how you do this problem. I hope you guys enjoy this video this problem is just Yet another two injured a problem. I'm going to explain the other two and another two videos and I'm going to upload those Sorry guys if I haven't been uploading at all lately, but I'm trying to keep up my upload schedule But yeah, rate com subscribe. I'll check you guys later. Peace