Created
December 23, 2015 19:17
-
-
Save AndreyBespamyatnov/0b92263ca7eef2e16127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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