Is there a way to replace two items that are next to each other with one item in array.
In array like this:
int[] array = new int[]{ 1, 2, 2, 3, 3, 4, 5, 3, 2 };
remove same items which are next to each other, resulting into this:
{ 1, 2, 3, 4, 5, 3, 2 };
Edit: Here what i end up with:
int[] array = new int[]{ 1, 2, 2, 3, 3, 4, 5, 3, 2 };
int last = 0;
List<int> Fixed = new List<int>();
foreach(var i in array)
{
if(last == 2 && i == 2 ||
last == 3 && i == 3)
{
}
else
{
Fixed.Add(i);
last = i;
}
}
return Fixed.ToArray() // Will return "{ 1, 2, 3, 4, 5, 3, 2 }"
but i must enter all the ones i want to skip...