223
List<string> listA = new List<string> { "a", "7", "1", "2", "3", "4", "5", "9", "7", "7", "1","222222222222222222","22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222323" };
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
//OPTIMIZEv2 - All BitArray imp - https://metadataconsulting.blogspot.com/2021/02/CSharp-dotNet-Get-difference-between-two-unordered-not-unique-lists-using-BitArrays-for-super-fast-speed.html
11
// - use ExceptIndistinct for >100 items
12
public static class Program
13
{
14
public static int loopcnt = 0;
15
16
//https://stackoverflow.com/questions/2975944/except-has-similar-effect-to-distinct
17
public static IEnumerable<T> ExceptFrom<T>(
18
this IEnumerable<T> first,
19
IEnumerable<T> second) //,
20
//IEqualityComparer<TSource> comparer)
21
{
22
if (first == null)
23
throw new ArgumentNullException();
24
Cached Result