Here is a novel way of achieving the result you require. Each array is converted into a string where each element is separated by a '*'. Matched strings are grouped together and the string and matches count are stored for each group. Finally, each string is deconstructed into an int[]
using an extension method and the results are enumerated. It is probably not the best way to go but it was fun to write
internal class Program
{
private static void Main(string[] args)
{
List<int[]> arrayList = new() { new int[] { 1,12,3 }, new int[] { 4,33,5},
new int[] { 1,12,3 }, new int[] { 4,33,5},new int[] { 4,33,5},new int[] { 6,7,8} };
int[][] jaggedArray = arrayList.ToArray();
StringBuilder sb = new();
List<string> list = new();
foreach (var array in jaggedArray)
{
sb.Clear();
foreach (var i in array)
{
sb.Append(i).Append('*');
}
list.Add(sb.ToString().TrimEnd('*'));
};
var res = list.GroupBy(s => s, (key, matches) => (Id: key, Count: matches.Count()));
List<(int[] array, int count)> result = new();
foreach (var (Id, Count) in res) result.Add((Id.ToIntArray(), Count));
foreach (var (array, count) in result)
{
Console.WriteLine($"{string.Join(',', array)}\t {count}");
}
Console.ReadLine();
}
}
public static class Extensions
{
public static int[] ToIntArray(this string s)
{
string[] elements = s.Split('*');
List<int> result = new();
foreach (var e in elements)
{
result.Add(Convert.ToInt32(e));
}
return result.ToArray();
}
}