Created
February 12, 2017 18:27
-
-
Save jakab922/b4f705238a237ed32e4a40f39e149545 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <iostream> | |
#include <string> | |
#include <algorithm> | |
using namespace std; | |
bool sol(string& s) { | |
bool total[26]; | |
fill_n(&total, 26, false); | |
for(char& c : s) { | |
if(total[c - 97]) { | |
return false; | |
} else { | |
total[c - 97] = true; | |
} | |
} | |
return all_of(begin(total), end(total), [] (bool b) { return b; }); | |
} | |
int main() { | |
string s("asdf"); | |
cout << sol(s); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment