title: find the number of ways you can form a string on size N, given an unlimited number of 0s and 1s
body: <p>The below question was asked in the <strong>atlassian company online test</strong> ,I don't have test cases , this is the below question I took from  this <a href="https://www.geeksforgeeks.org/atlassian-interview-experience-on-campus-august-2020/" rel="nofollow noreferrer">link</a></p>
  <pre><code>find the number of ways you can form a string on size N, given an unlimited number of 0s and 1s. But
      you cannot have D number of consecutive 0s and T number of consecutive 1s. N, D, T were given as inputs, 
  </code></pre>
  <p><strong>Please help me on this problem,any approach how to proceed with it</strong></p>
  <p>My approach for the above question is simply I applied recursion and tried for all possiblity and then I memoized it using hash map
  But it seems to me there must be some combinatoric approach that can do this question in less time and space? for debugging purposes I am also printing the strings generated during recursion, <strong>if there is flaw in my approach please do tell me</strong></p>
  <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  
  unordered_map&lt;string,int&gt;dp;
  int recurse(int d,int t,int n,int oldd,int oldt,string s)
  {
  
      if(d&lt;=0)
        return 0;
      if(t&lt;=0)
        return 0;
      cout&lt;&lt;s&lt;&lt;&quot;\n&quot;;
       if(n==0&amp;&amp;d&gt;0&amp;&amp;t&gt;0)
        return 1;
      string h=to_string(d)+&quot; &quot;+to_string(t)+&quot; &quot;+to_string(n);
  
      if(dp.find(h)!=dp.end())
       return dp[h];
      int ans=0;
      ans+=recurse(d-1,oldt,n-1,oldd,oldt,s+'0')+recurse(oldd,t-1,n-1,oldd,oldt,s+'1');
      return dp[h]=ans;
  }
  int main() 
  {
      int n,d,t;
      cin&gt;&gt;n&gt;&gt;d&gt;&gt;t;
      dp.clear();
      cout&lt;&lt;recurse(d,t,n,d,t,&quot;&quot;)&lt;&lt;&quot;\n&quot;;
      return 0;
  }
  </code></pre>