Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. /**
  2. * Find the smallest positive integer that does not occur in a given sequence.
  3. * @param {array} A
  4. * @param {int} result
  5. */
  6.  
  7. function solution(A) {
  8. const set = new Set(A);
  9. let i = 1;
  10.  
  11. while(set.has(i)) {
  12. i++;
  13. }
  14.  
  15. return i;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement