using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
CommonString
{
class Program
{
static void Main(string[]
args)
{
Console.Write("Please Enter a Number:- ");
int
n = Convert.ToInt16(Console.ReadLine());
List<string> list = new
List<string>();
string
input = string.Empty;
for
(int i = 0; i < n; i++)
{
input = Console.ReadLine().Replace("
","");
if
(!list.Contains(input.ToUpper())) {
list.Add(input.ToUpper());
}
}
string
smallestString=list.OrderBy(x => x.Length).First();
string
dstnctsmlString = new string(smallestString.ToCharArray().Distinct().ToArray());
int
listLength = list.Count;
int
characterCount = 0;
int
isfound = 0;
foreach
(char parentchar in
dstnctsmlString)
{
foreach
(var item in
list.Where(x => x != smallestString))
{
if
(item.Contains(parentchar))
{
characterCount++;
}
else
{
break;
}
}
if
(listLength-1 == characterCount)
{
Console.WriteLine("Matching Character::- "+
parentchar.ToString().ToLower());
isfound ++;
}
characterCount = 0;
}
if
(isfound == 0)
{
Console.WriteLine("No Matching Characters");
}
else
{
Console.WriteLine("So there was {0} matching Character" ,
isfound);
}
Console.ReadLine();
}
}
}