Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of K-Free Subsets

Count the Number of K-Free Subsets asks you to count subsets of an array of unique positive integers that contain no pair whose absolute difference equals k. The empty subset is valid.

Statement

You are given an array of unique positive integers nums and a positive integer k.

A subset of nums is called kk free if it does not contain any pair of elements with an absolute difference equal to k.

Return the total number of kk free subsets of nums.

Note: The empty set is considered a valid subset.

Constraints:

  • 1≤1 \leq nums.length ≤50\leq 50

  • 1≤1 \leq nums[i] ≤1000\leq 1000

  • 1≤1 \leq k ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of K-Free Subsets

Count the Number of K-Free Subsets asks you to count subsets of an array of unique positive integers that contain no pair whose absolute difference equals k. The empty subset is valid.

Statement

You are given an array of unique positive integers nums and a positive integer k.

A subset of nums is called kk free if it does not contain any pair of elements with an absolute difference equal to k.

Return the total number of kk free subsets of nums.

Note: The empty set is considered a valid subset.

Constraints:

  • 1≤1 \leq nums.length ≤50\leq 50

  • 1≤1 \leq nums[i] ≤1000\leq 1000

  • 1≤1 \leq k ≤1000\leq 1000