Last active
December 11, 2015 06:08
-
-
Save yasuharu519/4556691 to your computer and use it in GitHub Desktop.
CrackingTheCodeInterviewProblem1.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main(){ | |
char c; | |
bool chars[256]; | |
bool dup_flag = false; | |
fill_n(chars, 256, false); | |
while(std::cin >> c){ | |
if(!chars[c]){ | |
chars[c] = true; | |
}else{ | |
cout << "All of chars in input string is not unique" << endl; | |
dup_flag = true; | |
break; | |
} | |
} | |
if(!dup_flag) | |
cout << "All of chars in input string is unique" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment