Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace solutions
- {
- class Program
- {
- public static void Main()
- {
- var sets = Console.ReadLine().Split().Select(int.Parse).ToArray();
- var firstSet = new HashSet<string>();
- var secondSet = new HashSet<string>();
- var result = new HashSet<string>();
- for (int i = 0; i < sets[0] + sets[1]; i++)
- {
- var input = Console.ReadLine();
- if (i < sets[0])
- {
- firstSet.Add(input);
- }
- else
- {
- secondSet.Add(input);
- }
- }
- var minHash = new HashSet<string>();
- var maxHash = new HashSet<string>();
- if (firstSet.Count < secondSet.Count)
- {
- minHash = firstSet;
- maxHash = secondSet;
- }
- else
- {
- minHash = secondSet;
- maxHash = firstSet;
- }
- foreach (var item in minHash)
- {
- if (maxHash.Contains(item))
- {
- result.Add(item);
- }
- }
- Console.WriteLine(string.Join(" ", result));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement