Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Array_Ex
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] array1 = Console.ReadLine().Split(' ');
- string[] array2 = Console.ReadLine().Split(' ');
- int leftCount = 0;
- int rightCount = 0;
- int minLen = Math.Min(array1.Length, array2.Length);
- for (int i = 0; i < minLen; i++)
- {
- if (array1[i] == array2[i]) leftCount++;
- }
- int diff = Math.Max(array1.Length, array2.Length) - minLen;
- for (int i = minLen - 1; i >= 0; i--)
- {
- if (array1.Length < array2.Length && array1[i] == array2[diff + i])
- rightCount++;
- else if (array2.Length <= array1.Length && array2[i] == array1[i + diff])
- rightCount++;
- }
- Console.WriteLine(Math.Max(leftCount, rightCount));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement