Skip to content

Instantly share code, notes, and snippets.

@yasuharu519
Last active December 11, 2015 06:08
Show Gist options
  • Save yasuharu519/4556691 to your computer and use it in GitHub Desktop.
Save yasuharu519/4556691 to your computer and use it in GitHub Desktop.
CrackingTheCodeInterviewProblem1.1
#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