C++ DP Recursion + memoization
The recursion logic is basic\n\n1. if the last element in subset is not devisible then we have only 1 option of \n\t\t\t a)not including it  \n2. if the last el
The recursion logic is basic\n\n1. if the last element in subset is not devisible then we have only 1 option of \n\t\t\t a)not including it  \n2. if the last element int he subset is divisible by the present element , then there are two options,\n\t\t\t a) including it \n\t\t\t b) not including it \n\t\t\t \nThe memoization logic includes three parts, \n\n\t\t\ta) the present index\n\t\t\tb) the, answer till now vector size , and\n\t\t\tc) the last element placed in the subset\n```\nclass Solution {\nprivate:\n    vector<int>temp;\npublic:\n    void recur(vector<vector<int>>& dp, vector<int>& nums, vector<int>&ans, int x, int index)\n    {\n        if(ans.size()>temp.size())\n            temp=ans;\n        \n        if( index>=nums.size() or x>=nums.size())\n            return;\n        \n        if(dp[index][ans.size()]==x)\n            return;\n        \n        dp[index][ans.size()]=x;\n        \n        if(nums[index]%nums[x]==0 and nums[index]!=nums[x])\n        {\n            ans.push_back(nums[index]);\n            recur(dp,nums,ans, index, index+1);\n            ans.pop_back();\n        }\n        \n        recur(dp,nums, ans, x , index+1);\n    }\n    vector<int> largestDivisibleSubset(vector<int>& nums) \n    {\n        sort(nums.begin(),nums.end());\n        \n        vector<vector<int>>dp(nums.size()+1, vector<int>(nums.size()+1, -1));\n        \n        for(int i=0; i<nums.size(); i++)\n        {   \n            vector<int> yo={nums[i]};\n            recur(dp, nums, yo, i, 0);\n        }\n        \n        return temp;\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'C']