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

Envío 3834

Problema 0x5c - Decir si hay una letra repetida

  • Autor: bryancalisto
  • Fecha: 2021-04-17 23:07:52 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.004 s 12 KBi
#2
Correcto
0.005 s 2 KBi
#3
Correcto
0.008 s 1 KBi
#4
Correcto
0.005 s 2 KBi
#5
Correcto
0.007 s 6 KBi
#6
Correcto
0.003 s 13 KBi
#7
Correcto
0.005 s 2 KBi
#8
Correcto
0.005 s 47 KBi
#9
Correcto
0.005 s 21 KBi
#10
Correcto
0.007 s 3 KBi
#11
Correcto
0.003 s 2 KBi
#12
Correcto
0.007 s 1 KBi
Puntos totales: 100 / 100

Código

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define N_LETRAS 26

using namespace std;

int hashTable[N_LETRAS] = {0};
int _hash;

int main()
{
  string str;
  cin >> str;

  for (int i = 0; i < str.length(); i++)
  {
    _hash = (int)str[i] - 97;
    // cout << str[i] << " => " << _hash << endl;

    if (hashTable[_hash] > 0)
    {
      cout << "yes\n";
      return 0;
    }

    hashTable[_hash]++;
  }

  cout << "no\n";
  return 0;
}