VioletaBabel

1.1 중복이 없는가 본문

알고리즘문제들/코딩 인터뷰 완전 분석
1.1 중복이 없는가
Beabletoet 2017. 9. 5. 15:45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
#include<unordered_set>
#include<string>
using namespace std;
int main() 
{
    string str;
    cin >> str;
    unordered_set<char> hash;
    for (int i = 0; i < strlen(str.c_str()); ++i)
        if (hash.count(str[i]))
        {
            cout << "yes\n";
            return 1;
        }
        else
            hash.insert(str[i]);
    cout << "no\n";
    return 0;
}
cs


Comments