https://github.com/ayubamini/findsmallestpositiveinterger
A function to find the smallest positive integer (greater than 0) that does not occur in A
https://github.com/ayubamini/findsmallestpositiveinterger
array codility coding-challenge csharp netcore5
Last synced: about 1 month ago
JSON representation
A function to find the smallest positive integer (greater than 0) that does not occur in A
- Host: GitHub
- URL: https://github.com/ayubamini/findsmallestpositiveinterger
- Owner: ayubamini
- Created: 2021-06-27T05:11:58.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-27T17:29:08.000Z (almost 4 years ago)
- Last Synced: 2023-09-09T19:32:54.033Z (almost 2 years ago)
- Topics: array, codility, coding-challenge, csharp, netcore5
- Language: C#
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FindSmallestPositiveInterger
This is a demo task.
Write a function:
class Solution { public int solution(int[] A); }
that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.
For example,
Given A = [1, 3, 6, 4, 1, 2], the function should return 5.Given A = [1, 2, 3], the function should return 4.
Given A = [−1, −3], the function should return 1.
Write an efficient algorithm for the following assumptions:
N is an integer within the range [1..100,000];
each element of array A is an integer within the range [−1,000,000..1,000,000].