Jun 11, 2009

remove the duplicate elements from an array

remove the duplicate elements from an array

Int[] Remove(int[] arr)
{
Int j=0;
For(int i=1;i < arr.length();i++)
{
If (arr[j]==arr[i])
Continue;
Else
arr[++j]=arr[i];
}
For(int i=j+1;i < arr.length();i++)
Arr[i].delete();
Return arr;
}

No comments:

Post a Comment