题解 | #【模板】循环队列#
【模板】循环队列
https://www.nowcoder.com/practice/0a3a216e50004d8bb5da43ad38bcfcbf
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let len: number = 1;
let arr:string[] = [];
rl.on("line", function (line) {
const tokens = line.split(" ");
let one = tokens[0];
if (one == "push") {
if(arr.length < len){
arr.push(tokens[1]);
}else console.log('full');
}
else if (one == "pop") {
if (arr.length) {
console.log(arr.shift());
} else console.log("empty");
} else if (one == "front") {
if (arr.length) {
console.log(arr[0]);
} else console.log("empty");
}else len = parseInt(one);
});