Easiest Java Code Using Memoization || Recursion || Dynamic Programming
Here I am using dp Array for storing sizes of all subsets which satisfies the given condition\n\nclass Solution {\n    public List<Integer> largestDivisibleSubs
**Here I am using dp Array for storing sizes of all subsets which satisfies the given condition**\n```\nclass Solution {\n    public List<Integer> largestDivisibleSubset(int[] nums) {\n        Arrays.sort(nums);\n        ArrayList<Integer> res = new ArrayList<>();\n        int[] dp = new int[nums.length+1];\n        Arrays.fill(dp,-1);\n        solve(1,0,nums,new ArrayList<>(),res,dp);\n        return res;\n    }\n    void solve(int prev,int curr,int[] nums,ArrayList<Integer> currAns,ArrayList<Integer> res,int[] dp) {\n        if(curr >= nums.length) {\n            if(currAns.size() > res.size()) {\n                res.clear();\n                res.addAll(currAns);\n            }\n            return;\n        }    \n        if(dp[curr] < currAns.size() && (prev%nums[curr] ==0 || nums[curr]%prev == 0)) {\n            dp[curr] = currAns.size();\n            currAns.add(nums[curr]);\n            solve(nums[curr],curr+1,nums,currAns,res,dp);\n            currAns.remove(currAns.size()-1);\n        }\n        solve(prev,curr+1,nums,currAns,res,dp);\n    }\n}\n```
['Dynamic Programming', 'Memoization', 'Java']