You are viewing a single comment's thread. Return to all comments →
JS
var arr = input.split(/\r?\n/g).map((x) => { return x.split(' '); }); const results = []; for(let i = 1; i < arr.length; i++) { const query = Number(arr[i][0]); if(query === 3) { console.log(results[0]); } else if(query === 2) { results.shift(); } else { const elementToAdd = arr[i][1]; if(elementToAdd) { results.push(elementToAdd) } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Queue using Two Stacks
You are viewing a single comment's thread. Return to all comments →
JS