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 LargestCommonEnd
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] arr1 = Console.ReadLine().Split(new char[0], StringSplitOptions.RemoveEmptyEntries).ToArray();
- string[] arr2 = Console.ReadLine().Split(new char[0], StringSplitOptions.RemoveEmptyEntries).ToArray();
- int loop = Math.Min(arr1.Length, arr2.Length); // old int loop = Math.Min(arr1.Length, arr2.Length) - 1;
- int left = 0; int right = 0;
- for (int i = 0; i < loop; i++)
- {
- if (arr1[i] == arr2[i])
- {
- left++;
- }
- if (arr1[arr1.Length - i - 1] == arr2[arr2.Length - i - 1])
- {
- right++;
- }
- }
- if (left + right !=0)
- {
- Console.WriteLine(Math.Max(left, right));
- }
- else
- {
- Console.WriteLine(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement