Guest User

Untitled

a guest
Jul 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. function firstDuplicate(a) {
  2.  
  3. var b = [];
  4. for (i = 0; i < a.length; i++)
  5. {
  6. if(a[i] == b[a[i]])
  7. {
  8. return a[i];
  9. }
  10. else
  11. {
  12. b[a[i]] = a[i];
  13. }
  14. }
  15.  
  16. return -1;
  17. }
Add Comment
Please, Sign In to add comment