I have an array of strings ["abb", "bbxxaa"]
.
I would like to print all characters that occur equal times in each index so in above case I would print bb
because they occur twice in both indexes and a occurs once and twice in first and second index respectively.
My approach:
Keep track of only the characters in the first index and
because we would not need to worry about other letters anyway.
So in above case I would keep track of letter a
and b
and check if
they occur same time in the next indexes.
Can someone suggest a better way if possible or am I on right track?