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

Envío 4611

Problema 0x5c - Decir si hay una letra repetida

  • Autor: 7yrionLannister
  • Fecha: 2021-08-02 19:26:43 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.078 s 11 KBi
#2
Correcto
0.063 s 11 KBi
#3
Correcto
0.076 s 10 KBi
#4
Correcto
0.07 s 10 KBi
#5
Correcto
0.063 s 11 KBi
#6
Correcto
0.064 s 12 KBi
#7
Correcto
0.064 s 11 KBi
#8
Correcto
0.095 s 11 KBi
#9
Correcto
0.07 s 12 KBi
#10
Correcto
0.083 s 11 KBi
#11
Correcto
0.059 s 11 KBi
#12
Correcto
0.068 s 11 KBi
Puntos totales: 100 / 100

Código

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        boolean[] count = new boolean[26];
        String word = br.readLine();
        byte n = (byte) word.length();
        boolean yes = false;
        for (byte i = 0; i < n && !yes; i++) {
            if (count[word.charAt(i) - 'a']) {
                bw.write("yes\n");
                yes = true;
            } else {
                count[word.charAt(i) - 'a'] = true;
            }
        }
        if (!yes) {
            bw.write("no\n");
        }
        br.close();
        bw.close();
    }
}