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

Envío 2526

Problema 0x5c - Decir si hay una letra repetida

  • Autor: stivenxito
  • Fecha: 2020-12-30 00:59:14 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.124 s 12 KBi
#2
Correcto
0.132 s 12 KBi
#3
Correcto
0.181 s 12 KBi
#4
Correcto
0.148 s 15 KBi
#5
Correcto
0.183 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.148 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.176 s 16 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.158 s 16 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.187 s 12 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.142 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.139 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.185 s 12 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; 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");
 }
}