Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input){
- let cars = new Map();
- for (const line of input) {
- let [direction, plate] = line.split(', ');
- cars.set(plate,direction);
- }
- let output = (Array.from(cars)).filter(pair=>{
- return pair[1] !== 'OUT';
- });
- if(output.length !== 0){
- output.sort((a,b)=>{
- return a[0].localeCompare(b[0]);
- }).forEach(pair=>{
- console.log(pair[0]);
- });
- }else{
- console.log(`Parking Lot is Empty`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment