 What's up guys my name is Michael and welcome to my YouTube channel today We're doing another lead co-challenge called find common characters given an array a of the strings made only from lowercase letters return a list of all characters that show up in all strings within the list including duplicates for example for Character occurs three times in all strings, but not for you will need to include the character that appears three times in the final answer You may return the answer in any order. So in this case, there's Bella label roller E occurs once and every time. So we're gonna have E L occurs L occurs twice in every time. So we have two L's Okay, so in this case That's why it's ELL C occurs once every time in All these values C occurs once O occurs once every time For all values in this array. So we have O So I'm gonna give you guys a few minutes to do it and then I'll explain how I did it So based on my solution, I basically just have a array for that has the for each value inside the strings so you know You're given an array of strings right Bella label roller Basically create an array and for each value. I keep track of all 26 letters So how many times each letter occurred for every single value in the array? So in this case, that's what this count is So what do I do? I basically keep track of every single Number of occurrences every single letter appeared in each of these or in each of these Each of these Values in the array. So there's gonna be in this case a dot size Count is gonna have three three Three rows and number of columns is gonna be 26 represent every representing every single character Inside of count. That's what I'm doing here Okay, and then I have a vector to return to return the string of the occurrence of the The letter that occurs that many times inside the output array. Basically, that's what this output array to return is So I go through every single value inside the vector and I go through every single character and basically for every for every Row and Column, I'm going to essentially keep track of the number of times all the values appeared in so in this case Let's say I have Bella basically I'm going to have an array of 26 values for Bella and 26 is I'm gonna have an array of length 26 and I'm gonna keep track how many times each Character appeared in Bella. So a is gonna appear one time B is gonna appear one time e is gonna appear one time L is gonna appear twice everything else is gonna be zero. So that's what this loop here does it fills up My occurrences my arrays for every single letter for all these Values in the vector. That's what this is doing. I'm going through every single Every single value in the vector every single string in the vector of a the input array every single string Bella label roller I'm going to go through all the characters inside that string and I'm going to Get the integer equivalent value by minus in 97. That's gonna get me integer equivalent Starting a is gonna start at zero B's gonna start at one C's gonna start two That's what this is doing and I'm going to increase the count of that whatever at that position 26 I'm gonna increase the count of that then I'm gonna do is gonna go through all single every single Letter in the alphabet zero to 26 and I'm going to find the smallest Number of occurrences for every single letter. That's what I'm doing here. So I'm what I'm doing is I have a I set the smallest as the first first occurrences for every letter, right and I'm gonna compare Using men compare it to all the the rest of the values starting from 1 To the size of the number of occurrences and I'm gonna get the smallest for every single Character that's what I'm doing here. Okay, so the number the smallest of the number of occurrences for the character Okay, so in this case if e e shows up once and then e shows up once and e shows up once The smallest number of times for e is gonna be one and that's gonna be e here L shows up twice here L shows up twice here L shows up twice here Smallest the number of times L shows up is gonna be two so we're gonna Have L gonna be the number of occurrences for smallest of L is gonna be two once I do that I'm going to Decrement the smallest value for whatever character it is and I'm gonna push that many times of that character Into my to return array So if L if the smallest Occurrences for L is to every single time. I'm basically going to push To L twice so here L is gonna be appear twice here So that also fixes this part So in this case see if the small the number of times you occurs here is one Never times you curses one number times he occurs one. So the smallest number of times see occurs is one. So I push See once in the output array Number times zero. I owe occurs is two number times. Oh occurs one number times always occurs is two so What is that? I'm going to get the smallest which is gonna be one because Zero or the smallest of the number times zero I'm gonna find the number times. Oh occurred is one and I'm going to push that many times in the output array And I'm gonna return it. So that's basically how you do this Solution for five note common characters. I hope you guys enjoy this lead code Tutorial rate com subscribe check you out later. Peace