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

Envío 2930

Problema 0x5c - Decir si hay una letra repetida

  • Autor: hamorillo
  • Fecha: 2021-02-11 12:57:20 UTC (Hace casi 4 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.155 s 16 KBi
#2
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.151 s 15 KBi
#3
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.152 s 16 KBi
#4
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.157 s 15 KBi
#5
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.162 s 15 KBi
#6
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.161 s 16 KBi
#7
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.159 s 16 KBi
#8
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.161 s 53 KBi
#9
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.159 s 16 KBi
#10
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.16 s 16 KBi
#11
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.152 s 16 KBi
#12
Correcto
                      Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

                    
0.156 s 16 KBi
Puntos totales: 100 / 100

Código

import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Data data = readWordFromStdin();

        HashSet hashSet = new HashSet<Character>();

        for (char letter : data.word.toCharArray()) {
            if (hashSet.contains(letter)) {
                System.out.println("yes");
                return;
            } else {
                hashSet.add(letter);
            }
        }

        System.out.println("no");
    }

    private static Data readWordFromStdin() {
        Data data = new Data();
        Scanner in = new Scanner(System.in);

        data.word = in.nextLine();

        return data;
    }

    private static class Data {
        String word;
    }
}