-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayDiff.cs
More file actions
45 lines (38 loc) · 1.05 KB
/
Copy patharrayDiff.cs
File metadata and controls
45 lines (38 loc) · 1.05 KB
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
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace codeWarsArrayDiff
{
class Program
{
static void Main(string[] args)
{
//remove duplicates from 2 arrays
int[] a = {1, 2, 1, 4, 7 };
int[] b = {8, 2, 1, 4, 7 };
int[] after = Kata.ArrayDiff(a, b);
Console.WriteLine(after);
}
public class Kata
{
public static int[] ArrayDiff(int[] a, int[] b)
{
List<int> intListA = a.ToList();
List<int> intListB = b.ToList();
foreach (var item in intListA)
{
foreach (var item2 in intListB)
{
if (item == item2)
intListA.Remove(item);
}
}
a = intListA.ToArray();
b = intListB.ToArray();
return a;
}
}
}
}