题解 | 数独数组
数独数组
https://www.nowcoder.com/practice/12e6adfa05f5417dbf5a0d85ff5fb93c
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let n;
rl.on('line', function (line) {
const tokens = line.split(' ');
if (n === undefined) {
n = parseInt(tokens[0])
} else {
let c = new Array(9).fill(0)
for (const i of tokens) c[i - 1]++
const min = Math.min(...c)
c = c.map(e => e - min)
console.log(c.every(e => e <= 1) ? 'YES' : 'NO')
}
});
查看7道真题和解析
