Thank you so much mik. I wanted to let you know, me and my friends are learning from your playlists and we play it on speaker and everyone sits and listen and make notes. Thank you so much again for doing so much for us.
//ye bhi ho gaya khudse beacause of you class Solution { public: void backtrack(int idx, int n, vector& temp, vector& ans, vector& nums){ if(idx >= n){ return; } temp.push_back(nums[idx]); ans.push_back(temp); backtrack(idx+1, n, temp, ans, nums); temp.pop_back(); backtrack(idx+1, n, temp, ans, nums); } vector subsets(vector& nums) { int n = nums.size(); vector ans; vector temp; ans.push_back(temp); backtrack(0, n, temp, ans, nums); return ans; } };
Sir, why here temp.pop_back() is not given after the second recursive call? but given in 'generate paranthesis' question? When I removed the second pop back from generate paranthesis qn , it is not working. what is the difference between these two?
Take hint from this video. It will help to build the intuition for that also Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree | Broken in Steps | Leetcode-1489 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-gDPh7gsK3F8.html Let me know if that helps