 What's up guys, my name is Michael and welcome to my YouTube channel. Today we're going to do another lead code challenge DI string match Given a string as that contains only increasing and decreasing Such as I or D when it's increasing or decreasing Let n be equal to the length of the string return any permutation a of the numbers from 0 1 to n such that all the values of the index of I equal to 0 to n minus 1 is that if S of I at the index is an increasing one then the value at I and the value is less than the value at I plus 1 which is the one next to it if the value of S of I is equal to D then The value at the index of I is going to be greater than the one next to it. Okay? so In this case ID ID, it's going to go 0 4 1 3 2 1 1 1 I will be 0 1 2 3 D D DI is 3 2 0 1 Okay, so I'm just going to explain my solution because my internet just died and I don't really have a way to submit it so if you already saw my solution then Well good for you, but anyway, so what do I do? I create a vector called to return that has a size of the string and what I'm going to do is They they want you to alternate between if it's increasing 0 to 0 to 4 and then decreasing go to 4 to 1 increasing 1 Increasing is 1 to 3 decreasing is 3 to 2 right? So if you could see here If you go increase and decreasing you're actually just jumping places one adding one each time Right, so you go 0 and the next one is 1 and it's 2 right if you're decreasing You're actually just taking the size of the array one two three four Right, and you're decreasing it one every single time for three. So that is a That's basically what it's going on in the background if you're increasing increasing increasing I I I You're just adding one every single time 0 1 2 3 and If you're decreasing decreasing increasing You decrease decrease three two then it be you got to increase it says three. Oh We know yeah decrease decrease three two zero increase one. Okay, so essentially What I did was I have a Large value has a size and then the small value that has starting from zero and go through my String if I see an increasing I set my value at the certain index of my array Is going to equal to the smaller one and the reason why you're doing that is because as you can see here If you're increasing one two three, it's always a small number And that's what that's what it is and after that I post increment So increase smallest by one plus plus Right remember post increment is that this value is set to smallest first and then after this statement is done it Adds one to smallest afterwards. All right Otherwise if I'm decreasing it I said to return is you're going to equal to the largest which is my size That that takes an account of four in this case one two three four, right? That takes a count of four and then I said that equal to that then whenever I decrease again. I Do I have to subtract my largest by one? So then it becomes three four three As you can see your two jumps, you know four three. It's less than one every time then after my loop is done Sometimes you have to you have to push back smallest as well, which is just in case if that if not if not Do the last corner case if nothing occurred Such that it would still have smallest. Okay, so basically how do we do it? Ready calm subscribe. I'll tell you guys later. Peace