How would you calculate the intersection of characters between two strings?
For example (assuming we would have a method called String.intersection):
"abc".intersection("ab") = 2
"hello".intersection("hallo") = 4
Ok, boys and girls, thanks for your massive feedback. Some more examples:
"aaa".intersection("a") = 1
"foo".intersection("bar") = 0
"abc".intersection("bc") = 2
"abc".intersection("ac") = 2
"abba".intersection("aa") = 2
Some more notes:
Wikipedia defines intersection as follows:
Intersection of the sets A and B,
denoted A ∩ B, is the set of all
objects that are members of both A and
B. The intersection of {1, 2, 3} and
{2, 3, 4} is the set {2, 3}
This passes all your described test cases: