Skip to content

Instantly share code, notes, and snippets.

@jakab922
Created February 12, 2017 18:27
Show Gist options
  • Save jakab922/b4f705238a237ed32e4a40f39e149545 to your computer and use it in GitHub Desktop.
Save jakab922/b4f705238a237ed32e4a40f39e149545 to your computer and use it in GitHub Desktop.
#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