Assumed both string are case sensitive.
static string FindMatchString()
{
string string1 = "TodayisSaturday";
string string2 = "HowisSaturday";
string smallString = string1.Length > string2.Length ? string2 : string1;
string bigString = string1.Length > string2.Length ? string1 : string2;
string resultString = "";
int smallStringLen = smallString.Length;
int bigStringLen = bigString.Length;
for (int i = smallStringLen - 1; i >= 0; i--)
{
if (smallString[i] == bigString[bigStringLen - 1])
{
resultString = resultString + smallString[i].ToString();
}
bigStringLen--;
}
char[] arr = resultString.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}