-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo142.cs
37 lines (32 loc) · 1.01 KB
/
algo142.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Linq;
using System.Collections.Generic;
namespace HelloWorld
{
class Program
{
public static string[] inArray(string[] array1, string[] array2)
{
HashSet<string> result = new HashSet<string>();
foreach (var word1 in array1)
{
foreach (var word2 in array2)
{
if (word2.Contains(word1))
{
result.Add(word1);
break; // Diğer kelimeye geç
}
}
}
return result.OrderBy(w => w).ToArray();
}
static void Main(string[] args)
{
string[] a1 = new string[] { "arp", "live", "strong" };
string[] a2 = new string[] { "lively", "alive", "harp", "sharp", "armstrong" };
string[] result = inArray(a1, a2);
Console.WriteLine(string.Join(", ", result));
}
}
}