100% submission with 0ms time, C++ solution of simple recursion and backtracing
Time complexity: O(2^n)\nspace complexity: O(N)\n\n    class Solution {\n    public:\n        vector> ans;\n        void solve(vector &x,int i,vector &a){\n    
Time complexity: O(2^n)\nspace complexity: O(N)\n\n    class Solution {\n    public:\n        vector<vector<int>> ans;\n        void solve(vector<int> &x,int i,vector<int> &a){\n        ans.push_back(x);  \n    /*whenever an element is add from the vector it should be push back \n    as we need all the possible subset which will be generated in the recursive tree\n     as we want all the value of the recursive tree rather than the end values like in other question\n     hence we will have the ans.push_back on the top and will work ever time the recursive call take place*/\n        if(i==a.size()) return; \n    // this will end all the recursion as the i is now n that mean all values are taken onces\n        for(int j=i;j<a.size();j++){    \n    /*we start with j=i because if we have taken a value once then in next recursion\n     we need that our code see the next element and not the element which it had already worked\n     hence j=i where i will be increasing by 1 so that we can iterate the whole vector*/\n            if(i==j or a[j]!=a[j-1]){ // this is important \n                x.push_back(a[j]); \n    /* in subset 2 we have dublicate elements so to remove them we will have a \'if\' condition\n     where we will work only when the the current element is not equal to previous element\n     but this will also ignore the current element which will give worng answer\n     hence to make our code to work only once and take the current element\n    then ignore the other if they are same we use or function with i==j and arr[j]!=arr[j-1] \n    here i==j will allow use to take the element once rather than ignore all\n     the other condition will remove all dublicates*/\n                solve(x,j+1,a);\n                x.pop_back(); \n    // this is for backtracing as after one recursion we have to make our x empty again \n    //eg: [],[1],[1,2][1,2,2] non we will empty the x so that we can insert other value \n                }\n\t\t\t}   \n\t\t}\n   \n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        sort(nums.begin(),nums.end()); // sorting is must as our loop is checking only adjacent elements in the vector\n        vector<int> x;\n        solve(x,0,nums);\n        return ans;\n        }\n    };\n\n\n\n\nDO UPVOTE IF HELPED AND FEEDBACK PURELY WELLCOMED :)
['Backtracking', 'Recursion', 'C++']