Advertisement
Guest User

Untitled

a guest
Jul 25th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. bool is_unique_string(const std::string& s)
  2. {
  3.     std::array<bool, 1 << CHAR_BIT> tbl{};
  4.     for (auto x : s)
  5.     {
  6.         if (tbl[static_cast<unsigned char>(x)])
  7.             return false;
  8.         tbl[ static_cast<unsigned char>(x)] = true;
  9.     }
  10.    
  11.     return true;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement