title: Get all combinations without duplicates
body: <p>Give all possible combinations of a string without duplicates in c++. 
  Example input: "123" and output combinations will be:</p>
  
  <pre><code> 1,12,123,13,2,23,3.
  </code></pre>
  
  <p>An example of a duplicate would be "12"=="21" or "123"=="213". </p>
  
  <p>Assume a character will not be used more than once. Also I don't think recursion is mandatory.</p>
  
  <p>There's a php answer here.(<a href="https://stackoverflow.com/questions/43677563/get-all-possible-combinations-without-duplicates">Get all possible combinations without duplicates</a>).</p>
  
  <p>I have thought about some form of results tree but unsure how to implement with recursion.</p>
  
  <p>My answer that includes duplicates is below:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  void get( string str, string res ) {
  
     cout &lt;&lt; res &lt;&lt; endl;
  
     for( int i = 0; i &lt; str.length(); i++ )
        get( string(str).erase(i,1), res + str[i] );
  }
  
  int main( int argc, char **argv) {
     string str = "123";
     get( str, "" );
     return 0;
  }
  </code></pre>
  
  <p>This was an interview question and the no duplicates thing threw me. Thanks in advance for any help.  </p>