I came across a question which goes like this:
Given a list of strings, find the number of letters common to ALL elements. For example
mylist = ['abcdde',
'baccd',
'eeabg']
Required output: 2
Since only the letters 'a'
and 'b'
are common to all elements.
My logic was to somehow use set intersection to find the common elements. But I am not able to write code that can perform this.
Can someone please help. I would also like to have any other logic which can achieve the task more efficiently (if any).
Thanks