 What's up guys, Mike the Coder here today. We're gonna talk about C-S-E-S repetitions. All right, so you're given a DNA sequence. This is a string that contains the characters A, C, G, and T. So your task is to find the longest repetition in the sequence. This is a maximum length substring containing only one type of character. So what do they mean by this? It's just like, so if you look at this input example, A, T, T, C, G, G, G, A. The letter that appears the most number of times continuously in one sequence is G. All right, so G appears three times, right? And continuously from left to right next to each other. So that's why the answer is three because G appears three times, which is the largest number of times it appears. So like if we go to the beginning, we see like A appears once, right? T appears twice, C appears once, G appears three times, and then A appears once again. So in terms of like the maximum continuous time substring repeats, it's going to be G, right? G appears three times and the answer is G. They just want the maximum length. So how do you do this problem? This is actually a really basic problem. All you have to do is just loop from beginning to end and then just every time from that point of the index, keep track how many times it repeats from left to right. And then, yeah, loop from beginning to end and loop from that index and keep track how many times it repeats from beginning to end. Any time you encounter a new character that's not repeating, just reset the counter of how many times you want to repeat and check if it's like the maximum, right? So if it is greater than it, then that'll be the new counter of the new character that is repeating. And we want the length of it, so we just need to keep track of the length of it, okay? So here if we want to look at the code, I'll show you guys what I mean. So I have a string S that I'm going to input and then I set a long, long repetition is going to be long, long underscore minimum, which is the, it's like negative infinity, right? It's like the minimum possible, it could possibly occur, right? So the reason I do this is because I want to see, because we want the maximum, the maximum number, right? This is just like a placeholder so that any time we go loop through it, we'll get the maximum continuous letter in a row, right? When we keep track of it. So that's why this is equal to long, long underscore minimum. So the first for loop is to just loop from the beginning to end to loop through every character. And then now what we're going to do is we're going to have another pointer that's going to start from that position that we're looping through. And what we're going to do is while it's not, while it's less than to the end, we're going to check if it's equal to the one beside it, the one, the next one. So if it is equal to it, we're just going to keep increasing this pointer. So we're going to keep increasing it. And then once we reach this while loop, what this while loop is going to do is it's going to reach a point where the character is not going to equal to the next character, right? So what it means is like, I'm going to reach to a point where like sooner or later, one of the, one of the characters, J is not going to equal to J plus one, right? To the character afterwards. So that's what this while loop is going to do. And then after it's not equal to it, what we're going to do is we're going to get the length of it, right? And reset our length. And to get the length of it, what you do is if you start from the jth index, you're going to subtract from your current index and you add by one, cause I'll be the, the length of your index, the length of the string that you're keeping track of. So if we want to go over an example, essentially is here, if you have like AAAAA, it'll just start from A, start from zero, and it's going to loop to the end. And it's going to keep track until how many times of A's we encountered while it's equal to the next character. And then after it keeps track that many times, I want to hit like a C or a G or a T, then it'll stop. And then we just subtract like this position from the starting position and add one will give us the length of the current sequence. So that's what this is for, right? If I take the current position I'm at, after adding it in the subtract by the starting position, add one, that'll give me the length of the string. And then I set this equal to max rep, which is going to replace our answer. Our rep is the answer essentially. And then when this happens, I'm going to set my current pointer equal to the new pointer, because at this point, yeah, we don't need to check the next one, because if we check the next one, there's no reason to, because we know that this is the number of times it was equal to each other. So in that case, we could just skip all the way to the end of the iteration. And yeah, they'll all equal to that. So an example would be like in here, we have a C, C, G, G, G, T, D, D, D, right? Like if we start from A, I'll check, hey, is A equal to C? It's not equal to it. So we're going to get a length of A. So in this case, it's just going to be zero minus one, plus one, zero minus zero plus one, which is going to give us A. So I'll be one. And then we set a new pointer to equal to that. Now we're going to be at C. So we're going to loop from C to the end. So while C is equal to the next character, it's going to keep increasing it. So then in the end, we'll get two, right? We'll get two, because I'll be the length of C, how many times this repeats. And then we'll reset that as a new answer, right? Because we want the maximum length, right? The maximum answer. So we're going to set equal to max of that. So it'll be equal to two. And then the new pointer would be a point to the value after C, which is going to be G. And then we do the same thing for G. Count how many times there was repeated. And then once it is equal to it, we're going to jump to that next one, get the position, get the length of it, jump to the next one, and all the Ts, and so on and so forth. So yeah, the code looks like this. Some of you guys asked if you want the includes. The includes, the only thing that is really important that I have is just hashtag it define LL long, it has long, long. I didn't use the LL for long, long because I just assume all the inputs that I'm using is going to be super long. Yeah, because like in competitive programming, sometimes you might get overflow if you use integer. But yeah, you could just write long, long here, long, long. And yeah. So yeah, there's not much else I have in this code. So that's pretty much just a bit. Hope you guys enjoyed this video. It's just using two pointers. The first one, just looping through each character. And the second one is just keeping track of how many times it's repeated. And then we were just going to get the length of the position where it ends at. Subtract from the starting. Add one will give us length. And then we reset that. So yeah. Hope you guys enjoyed this video, write comments, subscribe, I'll check you guys later. Peace.