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

Envío 6394

Problema 0x5c - Decir si hay una letra repetida

  • Autor: Camilo15
  • Fecha: 2022-07-02 23:08:12 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#2
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#3
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#4
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#5
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#6
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#7
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#8
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#9
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#10
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#11
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
#12
Error de compilación
                      Main.java:7: error: method isRepeated in class Main cannot be applied to given types;
       System.out.println(isRepeated(word));
                          ^
  required: no arguments
  found:    String
  reason: actual and formal argument lists differ in length
Main.java:13: error: cannot find symbol
    for(Character c: word.toCharArray()){
                     ^
  symbol:   variable word
  location: class Main
2 errors

                    
Puntos totales: 0 / 100

Código

import java.util.*;
public class Main {

    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        String word = sc.nextLine();   
       System.out.println(isRepeated(word));
}

public static String isRepeated(){
    int [] letters = new int[26];

    for(Character c: word.toCharArray()){
    if(letters[c-'a']>0) return "yes";  
     
   letters[c-'a']++;
    }
 return "no";
}
  
}