█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 5579

Problema 0x5c - Decir si hay una letra repetida

  • Autor: pablopvsky
  • Fecha: 2022-01-10 22:17:38 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.039 s 7 KBi
#2
Correcto
0.029 s 6 KBi
#3
Correcto
0.071 s 33 KBi
#4
Correcto
0.02 s 6 KBi
#5
Correcto
0.02 s 7 KBi
#6
Correcto
0.025 s 6 KBi
#7
Correcto
0.025 s 7 KBi
#8
Correcto
0.063 s 19 KBi
#9
Correcto
0.023 s 6 KBi
#10
Correcto
0.023 s 6 KBi
#11
Correcto
0.024 s 6 KBi
#12
Correcto
0.024 s 6 KBi
Puntos totales: 100 / 100

Código

let readline = require("readline");

let LetterLog = [];
process.stdin.setEncoding("utf8");
let stdin = readline.createInterface({
  input: process.stdin,
  terminal: false,
});

stdin.on("line", readLine);

function readLine(line) {
  let wordLetters = [...line];
  let wordLength = wordLetters.length;

  for (let letter = 0; letter < wordLength; letter++) {
    let currentLetter = wordLetters[letter]
    let isIncluded = LetterLog.includes(currentLetter)

    if (isIncluded) {
      return console.log("yes");
    } if (letter === wordLength - 1) {
        console.log("no");
    } else {
        LetterLog.push(currentLetter)
    }

  }
}