Advertisement
Spocoman

02. Add and Remove

Jan 23rd, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     let print = [];
  4.     for(let i = 1; i <= input.length; i ++){
  5.         input[i - 1] === "add" ? print.push(i) : print.pop();
  6.     }
  7.     console.log(print.length > 0 ? print.join(" ") : "Empty");
  8.  
  9. }
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement