Help me out

How to know whether a character is present in two different words or not?
Like “o” is present in both words “boy” and “toy”.How will I print it.

You can run a check over the entire length of both the strings and check for the character?

You can make a frequency array and traverse both the strings.

If you encounter - ‘o’ , in the first string,then do a[int(‘o’)-96]++; don’t increment it again.

Now, traverse the second string and do the same thing :slight_smile:

Finally, if a[int(‘o’)-96]==2; then yes, ‘o’ is in both the strings !