<p>A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent&nbsp;the minutes (0-59). Each LED represents a zero or one, with the least significant bit on the right.</p>

<ul>
	<li>For example, the below binary watch reads <code>&quot;4:51&quot;</code>.</li>
</ul>

<p><img alt="" src="https://assets.leetcode.com/uploads/2021/04/08/binarywatch.jpg" style="width: 500px; height: 500px;" /></p>

<p>Given an integer <code>turnedOn</code> which represents the number of LEDs that are currently on (ignoring the PM), return <em>all possible times the watch could represent</em>. You may return the answer in <strong>any order</strong>.</p>

<p>The hour must not contain a leading zero.</p>

<ul>
	<li>For example, <code>&quot;01:00&quot;</code> is not valid. It should be <code>&quot;1:00&quot;</code>.</li>
</ul>

<p>The minute must&nbsp;consist of two digits and may contain a leading zero.</p>

<ul>
	<li>For example, <code>&quot;10:2&quot;</code> is not valid. It should be <code>&quot;10:02&quot;</code>.</li>
</ul>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> turnedOn = 1
<strong>Output:</strong> ["0:01","0:02","0:04","0:08","0:16","0:32","1:00","2:00","4:00","8:00"]
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> turnedOn = 9
<strong>Output:</strong> []
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>0 &lt;= turnedOn &lt;= 10</code></li>
</ul>

class Solution {
public:
    
    void solve3(int start,int n, vector<int> b, vector<string> &res, int sum)
         {
            if(n==0)
            {
                double d = sum/100.0;

                string str = to_string(d);
                str = str.substr(2,2);
                str = "0:"+str;
                res.push_back(str);
                sum=0;
                return ;
             }
            
        for(int i=start;i<b.size();i++)
        {
            sum+=b[i];
            solve3(i+1,n-1,b,res,sum);
            sum-=b[i];
        }
    }
    void solve(int start,int n, vector<int> b, vector<string> &res, int sum, int sum2)
    {
        if(n==0 )
        {
            if(sum2<60)
            {
                double d = sum2/100.0;

                string str1 = to_string(sum);
                string str = to_string(d);
                str = str.substr(2,2);
                str = str1+":"+str;
                res.push_back(str);
                sum=0;
            }
            return ;
        }
                
        for(int i=start;i<b.size();i++)
        {
            sum2+=b[i];
            solve(i+1,n-1,b,res,sum,sum2);
            sum2-=b[i];
        }
    }
    void solve1(int start, int n, int j,vector<int> a, vector<int> b, vector<string> &res, int sum)
    {
        if(n==0)
        {       
            if(j>0 && sum<12)
            {
               solve(0,j,a,res,sum,0) ;
            }
            else if(sum<12 )
            {
                string str = to_string(sum);
                str = str+":00";
                res.push_back(str);
                sum=0;
            }
            return ;
        }
        for(int i=start;i<b.size();i++)
        {
            sum+=b[i];
            solve1(i+1,n-1,j,a,b,res,sum);
            sum-=b[i];
        }
    }
    vector<string> readBinaryWatch(int n) {
        
        vector<int> a;
        a.push_back(1);
        a.push_back(2);
        a.push_back(4);
        a.push_back(8);
        
        
        vector<int> b;
        
        b.push_back(1);
        b.push_back(2);
        b.push_back(4);
        b.push_back(8);
        b.push_back(16);
        b.push_back(32);
        
        vector<string> res;
        //solve(0,n,b,res,0);
        for(int i=0;i<=n;i++)
        {
         if(i<5 && n-i<7)
           solve1(0,i,n-i,b,a,res,0);
        }
        
        sort(res.begin(),res.end());
        return res;
    }
};
10500