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 _01.Largest_Common_End
- {
- class Program
- {
- static void Main(string[] args)
- {
- var arr1 = Console.ReadLine().Split(' ').ToArray();
- var arr2 = Console.ReadLine().Split(' ').ToArray();
- int counterLeft = 0;
- int counterRight = 0;
- int iterationsCount = Math.Min(arr1.Length, arr2.Length);
- for (int i = 0; i < iterationsCount; i++)
- {
- if (arr1[i] == arr2[i])
- {
- counterLeft++;
- }
- }
- int index = 1;
- for (int i = iterationsCount - 1; i >= 0; i--)
- {
- if (arr1[arr1.Length - index] == arr2[arr2.Length - index])
- {
- counterRight++;
- index++;
- }
- }
- Console.WriteLine(Math.Max(counterLeft, counterRight));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment