Created
October 29, 2019 15:03
-
-
Save boriphuth/6083b3fbdfe0b4e6d8ada64e2a9ef671 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
class Solution { | |
public int solution(int[] A) { | |
// write your code in C# 6.0 with .NET 4.5 (Mono) | |
var set = new HashSet<int>(A); | |
foreach (int a in A){ | |
if (a > 0) { | |
set.Add(a); | |
} | |
} | |
// var array2 = set.ToArray(); | |
// Display the resulting array. | |
// Console.WriteLine(string.Join(",", array2)); | |
for (int i = 1; i <= A.Length + 1; i++) { | |
if (!set.Contains(i)) { | |
//Console.WriteLine(set.Contains(i)); | |
return i; | |
} | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment