1316. 그룹 단어 체커 - node.js / javascript

문제

내 코드

let fs = require("fs");
let input = fs.readFileSync("/dev/stdin").toString().trim().split("\n");

const N = Number(input.shift());
let answer = 0;

for (let word of input) {
  let temp = "";
  let isGroupWord = true;
  const endWords = [];

  for (let str of word) {
    if (str != temp) {
      if (endWords.includes(str)) {
        isGroupWord = false;
        break;
      } else {
        temp = str;
        endWords.push(str);
      }
    } else {
      continue;
    }
  }

  if (isGroupWord) {
    answer++;
  }
}

console.log(answer);

깃허브 링크

https://github.com/highjoon/JS_Algorithm/blob/master/BOJ/%EB%AC%B8%EC%9E%90%EC%97%B4/1316.js

좋은 웹페이지 즐겨찾기