SHARE
TWEET

Untitled

Coldsewoo Oct 17th, 2019 (edited) 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const arr = [3, 5, 5, 4, 3, 4, 8, 8, 2]
  2.  
  3. function findSingle(arr) {
  4.   const set = new Set()
  5.   while(arr.length) {
  6.     let temp = arr.pop()
  7.     if(!set.has(temp)) set.add(temp)
  8.     else set.delete(temp)
  9.   }
  10.   return Array.from(set.values()).pop() || null
  11. }
  12.  
  13. findSingle(arr)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top