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

Envío 2477

Problema 0x5c - Decir si hay una letra repetida

  • Autor: stivenxito
  • Fecha: 2020-12-23 02:47:45 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -2 out of bounds for length 26
	at Main.main(Main.java:10)
0.14 s 12 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -12 out of bounds for length 26
	at Main.main(Main.java:10)
0.14 s 12 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 26
	at Main.main(Main.java:10)
0.151 s 16 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -25 out of bounds for length 26
	at Main.main(Main.java:10)
0.155 s 15 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -21 out of bounds for length 26
	at Main.main(Main.java:10)
0.134 s 12 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 26
	at Main.main(Main.java:10)
0.15 s 16 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -19 out of bounds for length 26
	at Main.main(Main.java:10)
0.171 s 15 KBi
#8
Incorrecto
0.169 s 41 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 26
	at Main.main(Main.java:10)
0.16 s 16 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 26
	at Main.main(Main.java:10)
0.151 s 15 KBi
#11
Incorrecto
0.159 s 16 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 26
	at Main.main(Main.java:10)
0.142 s 12 KBi
Puntos totales: 0 / 100

Código

import java.util.Scanner;
class Main {
  public static void main(String[] args) {
   Scanner scan = new Scanner(System.in);
  
   String l = scan.nextLine();
   int[] letras = new int[26];
   boolean r = false;
   for(int i=0; i<l.length(); i++){
    letras['a'-l.charAt(i)]++;
    if(letras['a'-l.charAt(i)]>1){
     System.out.println("yes");
     break;
     }  
   }
  if(!r) System.out.println("no");
 }
}