<p>Given an integer array <code>nums</code>, return <em>all the different possible non-decreasing subsequences of the given array with at least two elements</em>. You may return the answer in <strong>any order</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [4,6,7,7]
<strong>Output:</strong> [[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]]
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [4,4,3,2,1]
<strong>Output:</strong> [[4,4]]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 15</code></li>
	<li><code>-100 &lt;= nums[i] &lt;= 100</code></li>
</ul>

class Solution {
public:
/*We saw that ki kaafi Permutations bnaune aa, hence Problem of backtracking.
Bcz har ek element vaaste check krna thus we use for loop from idx until n.
We need not call solve again in the case of exclude bcz i++ automatically ho he
reha hai loop de vich.
Set da use krke duplicates khatam krle, We just checked ki agar ek element use krlea
tn dwara oho use naa hove*/
vector<vector<int>>ans;
int n;
set<vector<int>>ans2;
// void solve(vector<int>&nums, int idx, vector<int>&output){
//     if(output.size() >= 2)
//     ans.push_back(output);
    
//     unordered_set<int>st; // Har recursive call da apna set hoega
//     for(int i=idx;i<n;i++){
//         if(output.empty() || nums[i] >= output.back() && st.find(nums[i]) == st.end()){
//             output.push_back(nums[i]);
//             st.insert(nums[i]);
//             solve(nums,i+1,output);
//             output.pop_back();
//             // solve(nums,i+1,output);
//         }
//     }
// }

// using Set of vectors
void solve(vector<int>&nums, int i, vector<int>&output){
    if(output.size() >= 2)
    ans2.insert(output);

    if(i >= n)
    return;

        if(output.empty() || nums[i] >= output.back()){
            output.push_back(nums[i]); // DO
            solve(nums,i+1,output); // EXPLORE
            output.pop_back();// REVERT
        }
        // Not Include wala case bahar, bcx we just i+1 from the index
            solve(nums,i+1,output);
}
    vector<vector<int>> findSubsequences(vector<int>& nums) {
        n = nums.size();
        vector<int>output;
        solve(nums,0,output);
        for(auto &vec : ans2)
        ans.push_back(vec);
        return ans;
    }
};
45660