class Solution:

    def beautifulSubsets(self, nums: List[int], k: int) -> int:

        temp = {num : 0 for num in nums}

        

        def backtrack(depth):

            if depth == len(nums):

                for t in temp:

                    if temp[t] > 0 and t + k in temp and temp[t + k] > 0:

                        return 0

                return 1

            ans = 0

            ans += backtrack(depth + 1)

            temp[nums[depth]] = temp[nums[depth]] + 1

            ans += backtrack(depth + 1)

            temp[nums[depth]] = temp[nums[depth]] - 1

            return ans

        

        return backtrack(0) - 1


여전히 백트래킹.. 이번주 컨셉은 백트래킹인가 봅니다.

12000ms인데도 통과는 되는 코드