C#: Smallest positive which is not present in an array
Write a C# Sharp program that takes an array of integers and finds the smallest positive integer that is not present in that array.
Sample Data:
({ 1,2,3,5,6,7}) -> 4
({-1, -2, 0, 1, 3, 4, 5, 6}) -> 2
Sample Solution:
C# Sharp Code:
Sample Output:
Original array elements: 1, 2, 3, 5, 6, 7 Smallest positive which is not present in an array: 4 Original array elements: -1, -2, 0, 1, 3, 4, 5, 6 Smallest positive which is not present in an array: 2
Flowchart:

C# Sharp Code Editor:
Contribute your code and comments through Disqus.
Previous C# Sharp Exercise: Sum of all prime numbers in an array.
Next C# Sharp Exercise: Find the product of two integers in an array.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.