数组A的部分数字子序列是整数的子序列,其中每个连续的整数至少有一个共同的数字
我保留一个包含0到9个字符的字典以及每个后续字符的计数.然后我循环遍历整数数组中的所有值并取每个数字并检查我的字典中该数字的计数.
public static void Main(string[] args)
{
Dictionary<char, int> dct = new Dictionary<char, int>
{
{ '0', 0 },
{ '1', 0 },
{ '2', 0 },
{ '3', 0 },
{ '4', 0 },
{ '5', 0 },
{ '6', 0 },
{ '7', 0 },
{ '8', 0 },
{ '9', 0 }
};
string[] arr = Console.ReadLine().Split(' ');
for (int i = 0; i < arr.Length; i++)
{
string str = string.Join("", arr[i].Distinct());
for (int j …Run Code Online (Sandbox Code Playgroud)