String manipulation
how to find out which character is similar between two string
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Munesh SharmaRank #174 · 13.9K reputationPosted Oct 10, 2014, 9:08 PM EDT
{
bool[] matchedFlag = new bool[s2.Length];
for (int i1 = 0; i1 < s1.Length; i1++)
{
for (int i2 = 0; i2 < s2.Length; i2++)
{
if (!matchedFlag[i2] && s1.ToCharArray()[i1] == s2.ToCharArray()[i2])
{
matchedFlag[i2] = true; break;
} }
}
return matchedFlag.Count(u => u);
}
VulpesRank #55 · 29.2K reputationPosted Oct 11, 2014, 3:51 PM EDT
The output is:
The common characters are : strng