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

Envío 2522

Problema 0x5c - Decir si hay una letra repetida

  • Autor: stivenxito
  • Fecha: 2020-12-30 00:54:08 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.145 s 16 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.131 s 17 KBi
#3
Correcto
0.188 s 25 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.153 s 16 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.155 s 16 KBi
#6
Incorrecto
0.131 s 35 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.202 s 28 KBi
#8
Incorrecto
0.134 s 14 KBi
#9
Incorrecto
0.14 s 15 KBi
#10
Incorrecto
0.133 s 23 KBi
#11
Incorrecto
0.14 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.181 s 24 KBi
Puntos totales: 9 / 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[l.charAt(i)-'a']>1) System.out.println("yes");
break;
  }
 if(!r) System.out.println("no");
 }
}