 Alright guys, we're gonna try to get go green from this It's gonna be my I Don't really have much time to do competitive programming Because they're just in a different time zone and have to do it to work, but today I could so I Haven't really practiced that much. Hopefully I could go green from this Can I turn on my camera? Let's see display capture. No Can you hear me? Hopefully you can I Don't know. Hmm. Okay So You have a bunch of change you write down all the prefeit. Okay, wait Mark. I love strings a lot He's a favorite string s for this we wrote down all it's on empty prefixes and suffixes You see all the strings one or Marcus favorite Paladro or not. You want to size the Paladro the PP Is prefix on me to be probably be is perfect. I'm okay, but what are we trying to do? He wrote down all it's not empty prefixes and suffixes on a piece of paper You see all these strings wonder Marcus favorite string is a paladrome or not. Oh Okay, okay Okay, we need to find the common character and then that specific index and then add the characters are not there onto it and then if If it's a paladrome, then we said yes all the way to say no So like a BCD the C is in the center. So we need to add a B in front of it and a D And then since there's a A here in front of the B. We need to add a A in front of it Um Yeah, I think Okay, this is a hard part. I don't know how to code it up though So I could easily take a tell us a pound or not Okay All right, we could definitely read in the input though What the fuck stop Okay, so read in T Okay So we could read in the input But we need to figure like add the whichever has the longest string might be ABC. I Oh, I oh I oh I They need to all have it in the B in the same same index so Like the most common character and then find like Build the string from that. That's what we have to do. I don't know how to code this though. Oh, this sucks Okay, a a B. Oh wait, wait We could just check all of them to see if there's a paladrome and if there's one that's not then it It's not I think wait, let me see the last one. Oh, no, that wouldn't work on the last one though Hmm because it would be TAL LTA. Oh My gosh, okay, we need to find the What is the longest string here? This should not be that hard, but I haven't practiced this a long time. Oh Okay, oh wait, no, but this is not a paladrome. Oh, no, but this is pal. Oh fuck, okay mmm Hard hard problem. Um, yeah, you have to build this original string up from the thing. Okay, so let me just try PCD a 1201 2 Zero one two zero one zero Okay um loop through every string then loop through every character if one of them is If you find a okay Replace every character with we need to keep track of the longest The most recent index of each letter then we could build a string off of that. I think yeah, yeah, okay And then that will be the actual Corresponding letter for the string and then we could build the string off and check if it's a paladrome. Okay, so yeah, okay, so here Reading this we're gonna loop through Shit, uh What oh Yeah, wait a second. It's not right All right, okay, okay, okay reading There's gonna be the current string what oh Oh, what the fuck? Okay? That's current shit. Okay. Now we're gonna loop through every character Inside the string and then each time you encounter We need a map that keeps track of the most recent string so so then we do index at C is gonna equal to Fuck yeah, so if Index at C is greater than zero So mean it exists We're gonna do Um, I can't do this. I have to do int i equals zero i less than Curr dot size i plus plus okay, so if index at cur at i If the index at the current a character is greater than zero, we're gonna replace the current index as a max of the current index With its With i Yeah Right. Yeah. Yeah. Yeah. Yeah, that's right. And then in the end We need to build our string and then check if it's a paladrome or not so we need to do Okay, so now we have all the characters and it's corresponding index That's the longest index and then now we just have to build our string from that. So Yeah, I don't actually know how I would do that Okay, so we do so let's say we had a was a zero D is One C is two D is three, right? So now I just need to Loop through every character in the map and then add it to my corresponding string. I Think I need to sort it by I have to sort it by Shit, I need to sort it by pair wise Not so I can't use a map This has to be like a vector of A pair So stupid A pair so if the current Index no, I can't do that either. Damn it. Okay, uh Okay We're gonna have to loop through the map and push everything into as net another array of Characters to integers for the index and then we need to Sort it by Sort it by increasing character Increasing index and then add it to our string in the end. Oh, man. This is so ridiculous. Okay So this time it's gonna be pair of int char This is gonna be like occur. I don't know placeholder. I don't know So we're gonna loop through So we're gonna loop through every corresponding character with its index and we're gonna push it into our placeholder. So placeholder the pushback X dot so X is the index here and there'll be X dot First yeah, no X dot second Second X dot first Yeah, and then we need a sort by So stupid sort placeholder by beginning and end and it's so stupid. All right now That's sorted by the increasing Index and its character now we could build our string. So now we have to do like Now this is sorted by index Yeah now now we just build our string. So we're gonna do V plus equal so it's I'm guessing starting from zero, right? So he's gonna plus equal to placeholder And I'm not a placeholder X dot What is it? Second? Yeah Yeah, yeah. Yeah, so he's gonna place you extra sign and now we need to check a visa palindrome So if is palindrome, I think I have a I think I have that function somewhere. Where are you? Where's where are you? Where are you? So if he is a palindrome, then we return do you see out? Yes. Otherwise, yeah, no, so Okay, this should work Although I don't know the time complexity Might be slow But you start to loop through every single one of these unless you're doing it using a try I don't think they would do that to us. I Did it did one problem. They're not gonna do that to us I did have to a problem. They wouldn't do that to us No, yes, it is. Oh, my last one says yes. Oh, that's not, right. Oh, what was he T? ALLT If they have the same number, that's a problem. Okay, wait, hold up, but I should have Already know that case though. This one's not right. Uh, one three God damn it. Why did I do that? It is not. Wait, wait, what the fuck? Somebody's not right. Oh, wait T. Wait, did I not read it, right? Something's really not right. Oh, I'm not reading input output, right? Wait Why is it put in this format? Let me check our ABC CD 80 ABC Oh, wait to n minus one. Oh fuck two Budge cakes. Um Okay, I need to loop through to two times n minus Okay, that's why I have to loop to That makes more sense Now I should read it properly What? No, no. Yes. No. No. Okay. That's something's not right. Uh, two n eight I was going to say one two three four five Two n is eight minus one six two zero one two three four five Wait two times eight I need to check if this is actually read in properly Okay, uh R should have ABC CD 80 ABC AB Yeah, that's right. Okay. So then this should we give me No, so let's continue Uh, let's see R should have IIO I oh, I This should give me yes Oh, I didn't input it in Uh, okay, I think you should just do max of it anyway All right. Now it should work first one should be no second one should be yes What why doesn't know fuck? I'm taking way too long in this problem This should go I should solve this normally it really fast. All right. What are the index? Uh, zero I Oh, it's not right Oh, but it doesn't matter because Actually, hold up I oh I zero zero one zero zero one Oh, you might need all the indexes fuck Well, if you need all the indexes then you don't even need um, let me see zero. Okay if I zero O is one okay zero zero I zero zero I zero O is one Oh zero, oh zero Oh zero. Okay. Oh zero. Okay. So we add a zero here I is one This is hard. All right, let me just look up how to build original string from prefix and suffixes You know where to do this Oh, wait, there's a match results. Maybe I'll use that function instead This is really hard I zero I I zero How much time do I have left? This should not be this hard. I spent 30 minutes on this problem. This should not be this hard If we could find you need to build a rebuild the original string, that's a problem Oh, okay. Um Find the most common character in all the strings loop from Each string to the end if one character is not there then um We're gonna add the characters at the end to that character um The character is there then we're going to I need to figure this out more. Okay, so t Fuck. Oh my god. Okay. T has zero. We have t zero. Um A is gonna have one I think Oh wait, a has zero. Okay. Hold on. There's so hard. So t we have zero one That's there L we have zero one. Okay Hey, we have zero So the problem is if they're both zero one You can't do it like that We need to find the character that is the most common In all the then add guys the end of it. That's what we need to do Let me check something If I use this Uh, what was the placeholder? Yeah, one one. That's that's problem We all have zeros If they're all in one eye, then How much time do I have left? I have an hour and 30. Okay, so I spent at least half an hour on this problem I have to be able to solve this problem and then With enough time, I should be able to try to solve the two. I don't know if I could solve 2b though Okay, I'm gonna go Get um I need to charge my laptop because my vlog was gonna die But yeah, I'm gonna be back real quick Okay. Okay. Uh, we need to figure this out I I I oh Oh I I oh I oh This is so hard This shouldn't be this hard They need to be all aligned Oh wait, um When the largest two lengths be the only one that matters Like b c d and a b c are the only ones that matter The rest of these don't matter a l and l t. Yeah b b a And a b b Only the largest ones are the ones that matter So The rest of them don't really matter that much So if we could find the largest ones Short by the largest lay Decreasing length and then maybe we could combine the strings together based on their corresponding character We need to add by the length Oh, this is so hard. This shouldn't be this hard This shouldn't be this hard I should be able to do this really fast I'm not seeing something l l t Man, I haven't practiced these problems in a long time. We're gonna get to green though if we will It shouldn't make any sense to be stuck in uh Gray for this law But yeah, New Year's resolution. I'll go green. I will I'll go green dude okay Let's go back to I I here I Find the most common character I would have four of these Oh to be there And then from there on we could just Append values after the most common character If they exist if they don't Yeah, okay. Yeah, we could try that I don't know what i'm going with this. Um This one doesn't work So we're gonna get rid of this Uh, okay, we're gonna find the most common character And then we're gonna add up characters Most common character here is I So then we're gonna loop through the whole array again and if we find a character We find the index of I And if there's values after it, we're gonna append it to our new string And if there are no values after it, if there are values before it, we'll append it to our current string Wait, I'm pretty sure we don't even need to do that I'm pretty sure a sort largest thing would work Okay, we'll try this again. Um We don't have to go through every string We have to just sort by largest Okay, sort r dot one dot size and smaller than two dot size This should work Uh, see how r at zero or something Yeah, get the two longest values and just combine them both see if they're a palindrome I think that would work I'm not sure for sure Why can I not do this? Oh, we're not increasing. Okay. Um, let me decrease it more. Okay. Um, okay So now we have the two largest ones No, we need to find out like the largest size Uh, we've got a break. That's so stupid Okay, so this is we're gonna end our Should be like End to size Okay, um Loop through all the values But we still need the most common character Is there a record of mine of both of these? Let's see abcd abc Oh, you can't wait. Hold on So stupid, uh My head hurts bba a bba a bbba If I I'm so ridiculous I'm trying to think See, I know how to I know an algorithm that would definitely work. I just don't know how to you would code it Like the best thing you could do is just place all of them on the spot and then build rebuild your string up Okay, um yeah The hard bro Find the most common character And just try to build a string off of that I'm kind of out of ideas right now I'm really out of ideas We're gonna find the most common character Yeah, so we kept track of all the characters and it's uh how many how often it occurred so here would be Oh shit, it'd be a person four times No, they both occurred. Oh damn Oh This is really hard. Oh, this is not that hard. This shouldn't be that hard. It should not be this hard It shouldn't be that hard. That's all the hard. It can't be this hard Al LT okay, LT. Okay. Okay. We got a on its own He's on his own. Okay. This is not so bad. It's so hard. It shouldn't be this hard Why is this one two three? Why is the fourth one yet? Oh, so Hmm That sucks Can we use two pointers on the last two? Oh, okay. Wait, I think I got it. I got it. I got it. I got it. Okay. So this is the last index for looping two Okay, we're going to here here Okay, we okay. So now what we're gonna do is we're gonna take two pointers so We're gonna try to merge the two strings together If that makes any sense So if we had let's say bcd And we have abc We start at the beginning bcd abc We find b and c if we can match it with a character in the second string and if we can't then um If it's not equal to it, we're going to add Add it to the front Add it to the back of the string So if we have zero zero b zero a zero Do you know if this is like geographically in order? Another thing we could check the occurrences of all the characters Visible by two mod by two Okay. Yeah, okay. Let's see um I need to rebuild my number of occurrences again Okay, maybe this will work No. Yes. Yes. No. Yes. No. Yes. Yes. No. Yes Hopefully this works Man, I spent an hour on this problem Dang wrong answer pretest too Oh, okay. Um Wait a second. Can you Hold up. No. Yes. Yes. Yes. Yes. Yes Okay, I think sorting by length would help a lot so i'm gonna go back to that so that I need this Uh, this part I don't need anymore. I don't know if getting the occurrences would help you here We want to sort it by length, but We need to like merge the two strings together every single one of them That's the hard part because if I have dba and have dbb Oh, wait, I've been looking at this so wrong We could solve this i oh We have regular i oh i so It could be i oh i or it could be Oh i oh hard problem Oh my gosh, this is so hard. I think the ad hoc is hurting my brain There shouldn't be this hard Wait, how many people solved this? Oh, what the fuck? I'm only on the six thousandth place Some people didn't solve this yet. I mean that's crazy. Wait, hold up Okay, I know the science did but did the green solve this? All the green solved it What the other grades? Now some of the grades solved it. Oh, no, okay Normally division one two a division two a shouldn't be this hard There's just something i'm not looking to see bcd ab abc I cruise the boat This is so hard This shouldn't be this hard ha t a l l t a Let me try something figure this out We're gonna figure this out Oh sort. Okay. Wait. What the fuck? What if you sort all them by by character? So a a l Let's sort it in alphabetical order Oh, okay, we sort them in alphabetical order and then we're gonna try to merge them together So a a It's really hard This is so hard Okay, we are gonna try to merge these together. Oh my god, this is hard This shouldn't I suck at strings. I need to do more string problems Okay, we're gonna have to go through each of these and then just try to merge them together. I hope So Okay, so we have the first one then we had to merge the second one and we need to Fuck, okay, it's gonna be similar to merge sort, but Should I create another function for this? Yeah, so if they're the same character, we're gonna add it to our new string If they're not we're gonna add the rest of it to our string So If this is smaller than that This is so hard It shouldn't be this hard Okay, um LT okay, we have ALLT. Okay, we have ALLT We saw half an hour left so God man, I really suck at these the strings. I gotta start doing more of these problems Oh, ad hoc problems ad hoc. You're gonna have you kill me every time. Okay, um Yeah, this is sorted by alphabetical order right now We need to merge them. So if the current string is smaller than the second one So, okay, so Okay, so we need to append them together so a No, you can't do that either. I was gonna I was gonna see something up with them if like any of these are like the same If there's no palindrome then There's no palindrome, but that's not true either Okay, we need to merge them. So we this really sucks. Okay, um Okay, okay if um If oh if they're if they're the same character then you need to add them Right, so if they if these are the same characters then um We need to add them to the string so to return plus equal One at i any of them. It's the same character And then if they're the same character, we're both move the pointer up by one. So i plus plus and the j plus plus Now if they're different characters So if the first one is small in the second one, so let's say it was like al and lt We only add the first character to the string And then we increment that up by one So we only add the first character. So Increment that pointer up if the second character is large in the first Then we only add the second character increment that up by one Um, and then in the end we need to add all the characters that are not done yet. So Um, okay, so that will do that. So those are the three scenarios and then we need to check if uh The characters are not done yet. We need to add those also so um, this is the two return plus equal one at i And then we need to do the same thing for the other one. We're going to return to return Okay, so that's the two pointer rule. Um Now now that we merged them together We should check it with the college room. We have to do God it's hard Okay, um Okay, so we're going to start First is going to be the first um first string and then we're going to try to merge it with every single other string And then we're going to store that value of first Uh, so second is going to equal to uh at i Okay, so we have we have the first string and then we're going to try to merge it with the second string and then from then on, um We're going to just continue trying to merge it with the second string So this is the first two is going to get merged into one And then we're going to try to take that merger with the second one take a result of that merge the third one So on and so forth. So this is going to be um Uh It's not going to be called first it's going to be called current And then current is going to now equal to the merged of those values And then in the end if um If it's not a palindrome, we're going to return um If there's a palindrome or c out yes Else c out no Uh, hopefully this works. This took so long. What is the error? Lost the data type. Um Oh, yes. No. Yes. Yes. Okay. No. Yes. Yes. No. Yes. Okay Uh, ideally this should work. It still doesn't work. I have no clue Damn it. Ah, it didn't work. What is the problem? I said we had abc bcd and um I can't I don't know how to build a suffix or a prefix and suffix array of abcde though Two times one two three four five ten minus two One two three four five six seven eight nine This is so hard. What is wrong with this? Why is this so hard? Okay, um bcd bc Pretty sure it merged it properly though. That's not what I want to do. Ah This problem's so hard Pretty sure it merged it properly though I see if the current test cases don't work. What does merge print out abc? abcd yeah Yeah, dude I'll understand man. This is so hard What am I doing wrong? I need to find like a way to generate all the prefix and suffixes And then see if I could like stress test this Because I'm pretty sure I merged it properly. We're gonna try to get to blue in one year Blue or actually we'll try to get to cyan. I think science possible green or cyan in one year All right, guarantee race to green. We're gonna try to do that every day We're gonna do a problem and then we're gonna try to do that and then Yeah, I'll see if I can grow this channel if I can't then I just can't Yeah, this is crazy, dude. This problem shouldn't be that hard. I merged it properly Um, let's see if I could find like a case where it doesn't work Let's say I'm a a a bb Not including itself Oh, shit. So it's one two three four You don't have a body They're all over now. We've got bc to leave all of ones from the end bcde Leave all are going to be getting Oh, we got to find a paladrome where this wouldn't work We need to find a case. I think I've been doing 17 minutes Let's have bc b ee one two three four five And I need um two times five is 10 much two is eight so I need 80s. Okay, so Okay, we got that and then we need to do this. Uh, you're in fact in front. So we could be cbe Cbe be and then he's done one two three four five six seven. What am I missing? Oh, eb Get rid of this this This one two three four five six seven. What am I missing one? So, you know, you one two three four five six seven eight Okay, let's try this one five Uh, ebcb ebc bcbe Uh cbe I'll see. How are you merging it? I don't know how that even worked out in the end. I don't think we're merging it properly although This could be either a possible string a return What is current one two three four five six seven Two times seven is 14 minus just 12 There should have 12 these one two three four five six seven What if I don't merge the rest bcbe Fuck if I add the front part not the not the back part e cbe Why is there a b in the end bcbe Sort of by size I picked the largest two and then merge it I'm nine minutes left. That's my that's my best thing I could think of right now This is the best I could think of I don't even it's left. Okay. Uh, we could try this ebc Oh, I need to merge these now. What should work come on work No, why aren't you working? I'm trying hard But so this worked what the fuck Wait, let me try one more thing. We have six minutes left. Hopefully this works Front time error. What the fuck maybe this will work I think it should how is this possible? I don't I don't I'm getting worse and worse The first two though three minutes left God God Man, we've we've fucked up this this so hard. It should be one and three. Okay End index should be Okay, what is end index? No, that's not right. That shouldn't be right. Um Oh, shit. It's dot size. I've got three minutes left This doesn't work then I ran out all ideas Did I try it all the time? Oh, yeah, I ran out of ideas I don't know I don't know why oh wait. It's gonna work Try one more time. I'm still not working Oh, I'm pretty sure the merge should have worked though The problem is it's getting like some strings are not the proper string Oh, man, let's go. Let's get cold in here. I won't eat some chicken nuggets I want you McDonald's. Hey guys, I couldn't solve this problem. I hope you guys know the video Ray cops subscribe. I'll check you guys later. I'm back guys. We're gonna try to get the green in one year. Peace