8 26 美团 前端 求教
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
// Write your code here
while ((line = await readline())) {
let tokens = line.split(" ").map(Number);
let nums = tokens[0];
let count = tokens[1];
let arr = new Array(nums).fill(0);
let flag = false;
for (let i = 0; i < count; i++) {
let operate = (await readline()).split(" ").map(Number);
if (operate[0] === 1) {
arr[operate[1] - 1] = 1;
} else {
for (let j = 0; j < arr.length; j++) {
if (j + 1 !== operate[1]) {
arr[j] = 1;
}
}
}
if (arr.filter((value) => value === 0).length === 0) {
flag = true;
console.log(i + 1);
break;
}
}
if (!flag) {
console.log(-1);
}
}
})();
家人们,我这段代码编译器报 let operate = (await readline()).split(" ").map(Number);这一行数组越界或语法错误,不知道问题出在哪儿了,谢谢!