title: Implement O(n) algorithm for determining if a string has all unique characters?
body: <p>Here I have O(n^2) algorithm implemented in C++ function to determine if a string have all unique characters.</p>
  
  <pre><code>bool IsUnique2(char *str)
  {
      char instr[256];
      strcpy(instr,str);
      bool repeat = false;
      int i;
      for(i = 0; i&lt;strlen(instr); i++)
      {
          int j;
          for(j=i+1; j&lt;strlen(instr); j++)
          {
              if(instr[i]==instr[j])
              {repeat = true; break;}
          }
          if(repeat) break;
      }
  
      return !repeat;
  }
  </code></pre>
  
  <p>This algorithm checks every char of the string with other char of the string in order to find if they are repeated.
  This approach have time complexity of O(n^2) with no space complexity. Can someone suggest an algorithm implementation of time complexity O(n) ?</p>