Showing posts with label Javascript Remove Duplicates in arrary. Show all posts
Showing posts with label Javascript Remove Duplicates in arrary. Show all posts

Monday, 28 July 2014

Javascript Remove Duplicates in arrary

int[] k = new int[] { 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 7, 8, 8, 9, 9, 9 };
for (int i = 0; i < k.Length - 1; i++)
{
if ((k[i] != k[i + 1]))
{
Response.Write(k[i]);
}
if ((k[k.Length - 2] == k[k.Length - 1]) && (i == k.Length - 2))
{
Response.Write(k[i]);
}
if ((k[k.Length - 2] != k[k.Length - 1]) && (i == k.Length - 2))
{
Response.Write(k[i + 1]);
}
}