+ 7
Increment duplicate elements
how to create a method to increment all duplicate element expect the first in a sorted array until obtain an array without any duplication items for example array={1,2,3,3,4,4} the solution: like this array={1,2,3,4,4,4} array={1,2,3,4,5,4} array={1,2,3,4,5,5} array={1,2,3,4,5,6}
1 Resposta
+ 2
bool success = false;
while(!success)
{
success = true;
foreach(int n in [array])
{
if([array].Contains(n))
{
n++;
success = false;
}
}
something like this? ;)
replace [array] with the name of your array.
Syntax errors might be included.