Skip to content

Instantly share code, notes, and snippets.

@boriphuth
Created October 29, 2019 15:03
Show Gist options
  • Save boriphuth/6083b3fbdfe0b4e6d8ada64e2a9ef671 to your computer and use it in GitHub Desktop.
Save boriphuth/6083b3fbdfe0b4e6d8ada64e2a9ef671 to your computer and use it in GitHub Desktop.
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