title: Find Unique Subsets problem different approach
body: <p>I have tried this solution to find subsets of a set but instead of using int I used strings as just got the question from a friend and didn't knew that it required integer input but the solutions I checked online have more time complexity than my solution, also sorry if I calculated the time complexity wrong, is this solution viable if the integer input from the question is converted to string and then back again to int when it is to be returned.</p>
  <p><b>I claim time complexity to be O(2<em>N)+O((2</em>N)+2)=O(N),N=size of string </b></p>
  <p>Pseudocode:</p>
  <p>Step0: Check for condition if size of string is!=1</p>
  <p>Step1: Store empty set in Subsets vector</p>
  <p>Step2: Till i is less than size of string push the single characters of string into Subsets vector</p>
  <p>Step3: After that push j,j+1 elements of string into Subsets and increment i,j</p>
  <p>Step4: If j==lastindex push first element of string+jth element of string into Subsets vector</p>
  <p>Step5: Print the elements of Subsets vector</p>
  <p>Step6: Push the string into Subsets vector</p>
  <p>Step7: If size==1 then push empty space and string into Subsets vector</p>
  <p>Step8: Print Subsets vector</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;bits/stdc++.h&gt;
  using namespace std;
  
  int main()
  {
      string n;
      cin&gt;&gt;n;
      int i=0,j=0;
      vector&lt;string&gt; Subsets;
      Subsets.push_back(&quot; &quot;);
      if(n.size()!=1)
      {
      while(i&lt;=(n.size()*2)) //O(2*N)
      {
          if(i&lt;n.size())
          {
              string temp;
              temp+=n[i];
              Subsets.push_back(temp);
              ++i;
          }
          else
          {
              string temp;
              temp+=n[j];
              temp+={','};
              temp+=n[j+1];
              Subsets.push_back(temp);
              ++i;
              ++j;
              if(j==n.size()-1)
              {
                  string temp1;
                  temp1+=n[0];
                  temp1+={','};
                  temp1+=n[j];
                  Subsets.push_back(temp1);
                  break;
              }
          }
      }
      
      Subsets.push_back(n);
      cout&lt;&lt;&quot;[&quot;;
      for(int i=0;i!=Subsets.size();++i) //O(2*n)+2
      {
          if(i==Subsets.size()-1)
          {
              cout&lt;&lt;&quot;[&quot;&lt;&lt;Subsets[i]&lt;&lt;&quot;]&quot;;
              break;
          }
          cout&lt;&lt;&quot;[&quot;&lt;&lt;Subsets[i]&lt;&lt;&quot;],&quot;;
      }
      cout&lt;&lt;&quot;]&quot;;
      }
      else{
          Subsets.push_back(n);
          for(int i=0;i!=Subsets.size();++i)
          {
              if(i==Subsets.size()-1)
              {
                  cout&lt;&lt;&quot;[&quot;&lt;&lt;Subsets[i]&lt;&lt;&quot;]&quot;;
                  break;
              }
              cout&lt;&lt;&quot;[&quot;&lt;&lt;Subsets[i]&lt;&lt;&quot;],&quot;;
      }
      }
  
      return 0;
  }
  </code></pre>