首页 > 代码库 > Cracking the Coding Interview 1-1

Cracking the Coding Interview 1-1

#include <iostream>#include <string>#include <algorithm>using namespace std;bool StringIsUnique(string s) {  sort(s.begin(),s.end());  for (auto p = s.begin(); p != s.end()-1;) {    if (*p == *++p) return false;  }  return true;}int main(int argc, const char * argv[]) {    string s = "akjnsdkjahrj";  cout << StringIsUnique(s) << endl;  string s2 = "qwertyuiop";  cout << StringIsUnique(s2) << endl;  return 0;}

 

Cracking the Coding Interview 1-1