111
Console.WriteLine("Result Unorderd Final A then B = " + (string.Join(",", diffAminusB)).Trim(',') + "," + string.Join(",", diffBminusA).Trim(',') + " in " + sw.ElapsedTicks + " ticks.");
1
using System;
2
using System.Collections;
3
using System.Collections.Generic;
4
using System.Linq;
5
using System.Diagnostics;
6
7
//CHALLENGE - Get difference between two unorderd, not unique lists, duplicates allowed within a list and across both lists.
8
//SOLUTION - https://metadataconsulting.blogspot.com/2021/02/CSharp-dotNet-Get-difference-between-two-unordered-not-unique-lists-aka-duplicates-allowed-within-a-list-and-across-both-lists.html
9
//OPTIMIZE - THIS IS IT using BitArray - https://metadataconsulting.blogspot.com/2021/02/CSharp-dotNet-Get-difference-between-two-unordered-not-unique-lists-lightning-fast-optimized.html
10
11
public class Program
12
{
13
public static int loopcnt = 0;
14
15
public static void Main()
16
{
17
Stopwatch sw = new Stopwatch();
18
sw.Start();
19
20
//RANDOM case - typical use ~ 78 ticks
21
string[] arrA = new string[] { "7", "1", "2", "3", "4", "5", "9", "7", "7", "1" };
22
string[] arrB = new string[] { "1", "1", "2", "2", "3", "4", "5", "5", "5", "5" };
23
24
//WANT 2,5,5,5,9,7,7,7
Cached Result