fix 1st thingy
This commit is contained in:
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user