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

Envío 6975

Problema 0x5c - Decir si hay una letra repetida

  • Autor: andres
  • Fecha: 2023-04-18 04:48:14 UTC (Hace alrededor de 1 año)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.004 s 1 KBi
#2
Correcto
0.004 s 1 KBi
#3
Correcto
0.005 s 0 KBi
#4
Correcto
0.004 s 1 KBi
#5
Correcto
0.004 s 1 KBi
#6
Correcto
0.005 s 1 KBi
#7
Correcto
0.005 s 2 KBi
#8
Correcto
0.004 s 1 KBi
#9
Correcto
0.004 s 1 KBi
#10
Correcto
0.005 s 1 KBi
#11
Correcto
0.004 s 0 KBi
#12
Correcto
0.005 s 2 KBi
Puntos totales: 100 / 100

Código

#include <iostream>
#include <cassert>

using namespace std;

int main() {
    string text;
    int textLenght = 50;
    cin >> text;

    assert(text.length() <= textLenght);
    bool repeated = false;

    for (int i = 0; i <= text.length(); i++) {
        for (int j = i + 1; j < text.length(); j++) {
            if (text[i] == text[j]) {
                repeated = true;
                break;
            }
        }

        if (repeated) {
            break;
        }
    }
    
    if (repeated) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }

    return 0;
}