I apologize for the confusing description. Recently interviewed at a company where I was asked this question for the phone interview. I was not able to solve it in the given time. Does anyone how to approach this?
Input: ["abc", "bcd", "cde"]
Output:
a -> [b,c] //a only appears with b and c
b -> [c] // c appears twice where b is present
c -> [b or d] //since both have same count where 'c' appears
d -> [c] //c has the highest count of 2
e -> [c, d] //only c and d appear with e
Hope this question makes sense. It took me sometime to understand it. I tried to loop through the array for each word and then loop through each char of word and get the frequency count and then loop again through the array again to see where it's present and update the count accordingly but it was very inefficient and confusing.
Hoping someone can provide a clearer insight on how to approach this. Tried to apply the concept of a frequency map but failed