 <p>A very simple (but rather memory expensive) way would be:</p> <pre><code>bool use_map(const std::string&amp; sentence) { std::set&lt;char&gt; chars(sentence.begin(), sentence.end()); return chars.size() == sentence.size(); } </code></pre> <p>If there's no duplicate chars, the sizes of both string and set will be equal.</p> <p>@Jonathan Leffler raises a good point in the comments: sentences usualy contain several whitespaces, so this will return <code>false</code>. You'll want to filter spaces out. Still, <code>std::set</code> should be your container of choice.</p> <p><strong>Edit:</strong></p> <p>Here's an idea for O(n) solution with no additional memory. Just use a look-up table where you mark if the char was seen before:</p> <pre><code>bool no_duplicates(const std::string&amp; sentence) { static bool table[256]; std::fill(table, table+256, 0); for (char c : sentence) { // don't test spaces if (c == ' ') continue; // add more tests if needed const unsigned char&amp; uc = static_cast&lt;unsigned char&gt;(c); if (table[uc]) return false; table[uc] = true; } return true; } </code></pre>