Last active
October 5, 2022 17:05
-
-
Save adicuco/d89e429d0acd0633fcde80b82b6e3346 to your computer and use it in GitHub Desktop.
100% solution for Missing Integer Task on Codility
This file contains hidden or 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
| function solution(A) { | |
| var max = 0; | |
| var array = []; | |
| for (var i = 0; i < A.length; i++) { | |
| if (A[i] > 0) { | |
| if (A[i] > max) { | |
| max = A[i]; | |
| } | |
| array[A[i]] = 0; | |
| } | |
| } | |
| if (max < 1) { | |
| return 1; | |
| } | |
| for (var j = 1; j < max; j++) { | |
| if (typeof array[j] === "undefined") { | |
| return j; | |
| } | |
| } | |
| return max + 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`
function solution(A) {
const set = new Set(A);
let missing = 1;
}
`