Pick / Not Pick || Python Explained
Intuition\nWe are supposed to count all subsets which have no elements such that there diff == k.\nSort the nums array and move with two options pick & notpick.
# Intuition\nWe are supposed to count all subsets which have no elements such that there diff == k.\nSort the nums array and move with two options pick & notpick.\nHow to pick elements?\na - b == k -> dontpick\na - k  == b -> dont pick\nWe can pick a element only if `a - k` not present in path.\nreturn count of all subsets.\n\n# Code\n```\nclass Solution:\n    def beautifulSubsets(self, nums: List[int], k: int) -> int:\n        nums.sort()\n        path = []\n        def recur(i, path):\n            if i >= len(nums):\n                if len(path) > 0:\n                  return 1\n                return 0\n            \n            notPick = recur(i+1, path)\n            pick = 0\n\n            if (nums[i] - k) not in path :\n                pick = recur(i+1, path + [nums[i]])\n            \n            return pick + notPick\n        count = recur(0, path)\n        return(count)\n\n        \n            \n\n\n```
['Python3']