Video solution | 2 approaches with intuition explained in detail | C++ | Backtracking
Video solution \nHello every one i have created a video solution for this problem and solved this video by developing intutition for backtracking ,its in hindi,
# Video solution \nHello every one i have created a video solution for this problem and solved this video by developing intutition for backtracking ,its in hindi, i am pretty sure you will never have to look for solution for this video ever again after watching this, here you will finally understand how to tackle array with duplicates.\n\nHere i have used 2 approaches:\n- without for loop\n- with for loop \n\nand these two approaches will help you to understand the confusion between recursion and backtracking, so that you can deep dive into backtracking without getting confused.\n\nThis video is the part of my playlist "Master backtracking".\nhttps://youtu.be/CqKyAIxAykA?si=Psmj2qkLVhMRhf-o\n\nPlaylist link: https://www.youtube.com/playlist?list=PLICVjZ3X1AcY5ai7at5OvS4ckXiMbWxCa\n\n# Code\n```\nclass Solution {\npublic:\nvoid subs(vector<int>& nums, vector<vector<int>>& res, vector<int>& sub, int idx) {\n        // 2 2 2 3\n        int l=nums.size();\n        res.push_back(sub);\n        for(int i=idx;i<l;i++){\n            if(i!=idx && nums[i]==nums[i-1]){\n                continue;\n            }\n            sub.push_back(nums[i]);\n            subs(nums, res, sub,i+1);\n            sub.pop_back();\n        }\n        return;\n        \n        \n    }\n    vector<vector<int>> subsetsWithDup(vector<int>& nums) {\n        vector<int> sub;\n        sort(nums.begin(),nums.end());\n        vector<vector<int>> res;\n        subs(nums, res, sub, 0);\n        return res;\n    }\n};\n```
['Backtracking', 'Recursion', 'C++']