Envío 6977
- Autor: andres
- Fecha: 2023-04-18 07:08:07 UTC (Hace alrededor de 2 meses)
Caso # |
Resultado |
Tiempo |
Memoria |
#1 |

Correcto
|
0.112 s
|
13 KBi |
#2 |

Correcto
|
0.072 s
|
16 KBi |
#3 |

Correcto
|
0.109 s
|
13 KBi |
#4 |

Correcto
|
0.073 s
|
16 KBi |
#5 |

Correcto
|
0.088 s
|
16 KBi |
#6 |

Correcto
|
0.079 s
|
17 KBi |
#7 |

Correcto
|
0.076 s
|
16 KBi |
#8 |

Correcto
|
0.109 s
|
13 KBi |
#9 |

Correcto
|
0.114 s
|
13 KBi |
#10 |

Correcto
|
0.122 s
|
13 KBi |
#11 |

Correcto
|
0.116 s
|
13 KBi |
#12 |

Correcto
|
0.104 s
|
13 KBi |
Puntos totales: 100 / 100
Código
import java.util.HashMap;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
HashMap<Character, Integer> map = new HashMap<>();
int index = 50;
String text;
text = scan.nextLine();
scan.close();
for (int i = 0; i < text.length(); i++) {
char current = text.charAt(i);
if (!map.containsKey(current)) {
map.put(current, i);
} else {
if (map.get(current) < index) {
index = map.get(current);
}
}
}
if (index != 50) {
System.out.println("yes");
} else {
System.out.println("no");
}
}
}