Skip to content

Instantly share code, notes, and snippets.

@AndreyBespamyatnov
Created December 23, 2015 19:17
Show Gist options
  • Save AndreyBespamyatnov/0b92263ca7eef2e16127 to your computer and use it in GitHub Desktop.
Save AndreyBespamyatnov/0b92263ca7eef2e16127 to your computer and use it in GitHub Desktop.
// You've got an array of ints 2,2,3,3,4,5,5... Find an element without a pair.
class Program
{
static void Main(string[] args)
{
var array = new int[] {2, 2, 3, 3, 4, 5, 5};
var array2 = new int[array.Length];
foreach (var a in array)
{
if (array2[a] == 0)
{
array2[a] = a;
}
else
{
array2[a] = -1;
}
}
foreach (var i in array2)
{
if (i > 0)
{
Console.WriteLine(i);
}
}
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment