Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace ExamPreparation
- {
- class Startup
- {
- static void Main()
- {
- string[] firstTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- string[] secondTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- int startCount = 0;
- if (firstTokens.Length <= secondTokens.Length)
- {
- startCount = firstTokens.TakeWhile((element, index) => element == secondTokens[index]).Count();
- }
- else
- {
- startCount = secondTokens.TakeWhile((element, index) => element == firstTokens[index]).Count();
- }
- Array.Reverse(firstTokens);
- Array.Reverse(secondTokens);
- int endCount = 0;
- if (firstTokens.Length <= secondTokens.Length)
- {
- endCount = firstTokens.TakeWhile((element, index) => element == secondTokens[index]).Count();
- }
- else
- {
- endCount = secondTokens.TakeWhile((element, index) => element == firstTokens[index]).Count();
- }
- if (startCount >= endCount)
- {
- Console.WriteLine(startCount);
- }
- else
- {
- Console.WriteLine(endCount);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement