You are viewing a single comment's thread. Return to all comments →
Javascript solution
const s = input.split("\n"); const queue = [] s.shift() s.forEach(op => { if(op.startsWith("1")) { queue.push(op.split(" ")[1]) } if(op === '2') { queue.shift(); } if(op === '3') { console.log(queue[0]) } })
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 →
Javascript solution