-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1316.js
38 lines (32 loc) · 793 Bytes
/
1316.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var readline = require("readline");
var r = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
r.on("line", function (line) {
input.push(line);
}).on("close", function () {
main(input);
process.exit();
});
let checkChar = [];
function main(input) {
const [N, ...words] = input;
let result = 0;
words.forEach(word => {
let temp = false
word.split('').forEach((chr, i) => {
if (checkChar.indexOf(chr) === -1) {
checkChar.push(chr);
} else {
if (word.split('')[i - 1] !== chr) {
temp = true;
}
}
})
checkChar = []
if (temp) result++
});
console.log(+N - result);
}