Created
December 23, 2015 19:54
-
-
Save AndreyBespamyatnov/bf1d6e6d90e04f07c6f5 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, 6, 9}; | |
var array2 = new int[array.Length]; | |
for (int index = 0; index < array.Length; index++) | |
{ | |
var a = array[index]; | |
var nxtIndex = index + 1; | |
if (nxtIndex == array.Length) | |
{ | |
Console.WriteLine(a); | |
break; | |
} | |
var b = array[nxtIndex]; | |
if (b != a) | |
{ | |
Console.WriteLine(a); | |
} | |
else | |
{ | |
index++; | |
} | |
} | |
Console.ReadKey(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment