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

Envío 2527

Problema 0x5c - Decir si hay una letra repetida

  • Autor: stivenxito
  • Fecha: 2020-12-30 00:59:42 UTC (Hace casi 4 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.StringIndexOutOfBoundsException: String index out of range: 5
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at Main.main(Main.java:10)
0.145 s 16 KBi
#2
Correcto
0.134 s 12 KBi
#3
Correcto
0.151 s 16 KBi
#4
Correcto
0.156 s 16 KBi
#5
Correcto
0.131 s 12 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 27
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at Main.main(Main.java:10)
0.137 s 16 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 27
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at Main.main(Main.java:10)
0.175 s 12 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 27
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at Main.main(Main.java:10)
0.165 s 12 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 27
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at Main.main(Main.java:10)
0.129 s 16 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 27
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at Main.main(Main.java:10)
0.137 s 12 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 50
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at Main.main(Main.java:10)
0.135 s 12 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 50
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at Main.main(Main.java:10)
0.169 s 16 KBi
Puntos totales: 34 / 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() || r==true; i++){
    letras[l.charAt(i)-'a']++;
    if(letras[l.charAt(i)-'a']>1) r = true;
  }
 if(!r) System.out.println("no");
 else System.out.println("yes");
 }
}