Hi,
For example, there is two string:
string str1 = "abcde";
string str2 = "abccc";
The common chars are:
a, b, c from str1, and a, b, c, c, c from str2.
So, the sum of these common char(s) is 3 + 5 = 8.
Could someone show me a function that can do this?
public int FindCommonChars(string str1, string str2)
{
....
}
I have written one 2x nested loop, but it seems very ... (you know)
/*
int i = 0;
foreach(char c1 in str1)
{
foreach(char c2 in str 2)
{
if(c1 == c2) i++;
}
}
foreach (char c2 in str 2)
{
foreach(char c1 in str1)
{
if(c2 == c1) i++;
}
}
return i;
*/
T_T, the Questioner very very contempt my answer:(