SHARE
TWEET

Untitled

a guest Mar 8th, 2020 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function partyTime(input = []) {
  2.   let vipGuestsList = new Set();
  3.   let regularGuestsList = new Set();
  4.   let reservation;
  5.   while ((reservation = input.shift()) !== "PARTY") {
  6.     if (reservation[0] == Number(reservation[0])) {
  7.       vipGuestsList.add(reservation);
  8.     } else {
  9.       regularGuestsList.add(reservation);
  10.     }
  11.   }
  12.  
  13.   for (let guest of input) {
  14.     if (vipGuestsList.has(guest) || regularGuestsList.has(guest)) {
  15.       if (guest[0] == Number(guest[0])) {
  16.         vipGuestsList.delete(guest);
  17.       } else {
  18.         regularGuestsList.delete(guest);
  19.       }
  20.     }
  21.   }
  22.  
  23.   console.log(vipGuestsList.size + regularGuestsList.size);
  24.   vipGuestsList.forEach(el => console.log(el));
  25.   regularGuestsList.forEach(el => console.log(el));
  26. }
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
Top