Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve2(arr) {
- const parkingLot = new Set();
- for (const entry of arr) {
- const [dir, plate] = entry.split(', ');
- switch (dir) {
- case 'IN': {
- parkingLot.add(plate);
- break;
- }
- case 'OUT': {
- parkingLot.delete(plate);
- break;
- }
- }
- }
- if (parkingLot.size > 0) {
- [...parkingLot]
- .sort((a, b) => a.localeCompare(b))
- .forEach(carNumber => {
- console.log(carNumber);
- });
- }
- else {
- console.log('Parking Lot is Empty');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement