using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { // Read input sizes Console.Write("Enter size of first array (n): "); int n = int.Parse(Console.ReadLine()); Console.Write("Enter size of second array (m): "); int m = int.Parse(Console.ReadLine()); // Read first array Console.WriteLine($"Enter {n} elements for the first array:"); int[] arr1 = Console.ReadLine().Split().Select(int.Parse).ToArray(); // Read second array Console.WriteLine($"Enter {m} elements for the second array:"); int[] arr2 = Console.ReadLine().Split().Select(int.Parse).ToArray(); // Compute union, remove duplicates, and sort List unionResult = arr1.Concat(arr2).Distinct().OrderBy(x => x).ToList(); // Print result Console.WriteLine("Union of the arrays (sorted): " + string.Join(" ", unionResult)); } }