You are viewing a single comment's thread. Return to all comments →
My Solution in Javascript also works with TypeScript:
function processData(input) {
const query = input.split('\n').slice(1) const answer = [] for(let i = 0; i < query.length; i++) { if(query[i].charAt(0) === '1') { const [index, number] = query[i].split(' ') answer.push(number) } if(query[i].charAt(0) === '2') { answer.shift() } if(query[i].charAt(0) === '3') { console.log(answer[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 →
My Solution in Javascript also works with TypeScript:
function processData(input) {
}