摘要:
假设是ASCII字符集,开一个128大小的bitset来记录每个字符。#include #include #include bool isUniqueChars(std::string s){ std::bitset a; size_t len = s.length(); for (size_t i = 0; i < len; ++i) { char idx = s[i]; if (a.test(idx)) { return false; } a.set(idx); } return true;} 阅读全文