I have a vector of strings
example:
dedf
eedf
fedf
hedf
I want to go through the list and count how many times each letter appears
so for example the letter
d appears 5 times
e appears 5 times
f appears 5 times
h appears 1 time
I don’t have no code so far but I’m trying to see how I can do this with logic first.
I’m trying to code but don’t know where to start.
I was thinking I can store each letter into a string.
string would be {dedfeedffedfhedf}
Then take the string and count each time the letter is in that string
but this is where I’m having a problem. Any thoughts?
Any suggestions would also be appreciated.
Thank You
You can have an array for holding the counts of each letter. If we’re assuming just the alphabet, you’ll have an array of 26 elements (likely ints), all initialized to 0. Then you can go through each string, and each time you encounter a character, you increment that count.
And then you do whatever you want with the counts.