Java Clean Solution | With Detail Explanation
Complexity\n- Time complexity:O(2^n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity:$$O(2^n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    List<List<Integer>> list = new ArrayList<>();\n\n    // BACKTRACKING\n    private void solveBacktrack(int[] nums, int idx, int k, List<Integer> i_list) {\n        // Base Case\n        if (idx >= nums.length) {\n            if (i_list.size() > 0) {\n                list.add(i_list);\n            }\n            return;\n        }\n\n        // take it\n        if (!(i_list.contains(nums[idx] - k))) {\n            // Backtracking...\n            i_list.add(nums[idx]);\n            solveBacktrack(nums, idx + 1, k, i_list);\n            i_list.remove(i_list.size() - 1);\n        }\n\n        // non-take\n        solveBacktrack(nums, idx + 1, k, i_list);\n    }\n\n    public int beautifulSubsets(int[] nums, int k) {\n        Arrays.sort(nums);\n\n        solveBacktrack(nums, 0, k, new ArrayList<>());\n        return list.size();\n    }\n}\n```
['Array', 'Dynamic Programming', 'Backtracking', 'Recursion', 'Memoization', 'Sorting', 'Java']