fix 1st thingy

This commit is contained in:
KaseToatz1337
2024-10-03 15:32:25 +02:00
parent 49a3e34610
commit 58ebd8c8b8

View File

@ -15,23 +15,27 @@ namespace BAI
/// ------------------------------------------------------------
public static void Opdr1FilterList(List<int> lijst)
{
Dictionary<int, int> occurences = [];
foreach (int i in lijst)
Dictionary<int, int> positions = [];
for (int i = 0; i < lijst.Count; i++)
{
if (occurences.TryGetValue(i, out int value))
if (positions.TryGetValue(lijst[i], out _))
{
occurences[i] = ++value;
positions[lijst[i]] = -1;
}
else
{
occurences[i] = 1;
positions[lijst[i]] = i;
}
}
foreach (int i in occurences.Keys)
for (int i = 0; i < lijst.Count;)
{
if (occurences[i] == 1)
if (positions[lijst[i]] != -1)
{
lijst.Remove(i);
lijst.RemoveAt(i);
}
else
{
i++;
}
}
}