Sonoa Systems Interview Question
Testing / Quality Assurancesusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace RemoveDupsinArray
{
class Program
{
static void Main(string[] args)
{
int[] array = { -4, 0, 1, 6, 0, 1, 6, -2 };
RemoveDups(array);
Console.Read();
}
public static void RemoveDups(int[] array)
{
Hashtable ht = new Hashtable();
string output = "";
for (int i = 0; i < array.Length; i++)
{
if (!ht.ContainsKey(array[i]))
{
ht.Add(array[i],0);
output += " " + array[i];
}
}
Console.WriteLine("{0} ", output);
}
}
}
output: -4 0 1 6 -2
Use Hashtable
- Anonymous June 22, 2010