java 15ms dp solution beats 97%
The basic idea is as given below,\n1. if input is empty return empty list\n2. sort the array so that you can identify elements with values less than them and we
The basic idea is as given below,\n1. if input is empty return empty list\n2. sort the array so that you can identify elements with values less than them and we need to check modulo(%) only upto the current element.\n3. For each item **`a`** in the array, identify the item **`b`** less than the current item with max number of items in the set . This data need to be stored in an array and in below code array **c** contains this data and along with this keep track of **b** for all **a** by using another array **dp**.  \n4. If the current **c[i]** value found in above step is the maximum we found so far, update the **max** variable to point to **c[i]** \n5. Backtrack **dp** array from **max** index and create the list for the calculated number of items\n\n```\n\n    public List<Integer> largestDivisibleSubset(int[] nums) {\n        if(nums.length == 0){\n            return Collections.emptyList();\n        }\n        Arrays.sort(nums);\n        int length = nums.length;\n        int[] c = new int[length];\n        int[] dp = new int[length];\n        Arrays.fill(c, 1);\n        int max = 0;\n        for (int i = 1; i < length; i++) {\n            int e = nums[i];\n            for (int j = 0; j < i; j++) {\n                if (e%nums[j] == 0) {\n                    if(c[i] < c[j]+1){\n                        dp[i] = j;\n                        c[i] = c[j]+1;\n                    }\n                }\n            }\n            if(c[i] > c[max]){\n                max = i;\n            }\n        }\n        List<Integer> r = new ArrayList<>();\n        int k =max;\n        for (int i = c[max]; i > 0; i--) {\n            r.add(nums[k]);\n            k = dp[k];\n        }\n        return r;\n    }\n```
[]