Given an array of positive integers `weights` and a positive integer `capacity`, your task is to determine the total count of distinct non-empty subsets of `weights` such that the sum of elements in each subset is less than or equal to `capacity`. Each element from the input `weights` array can be used at most once in a single subset.
Explanation: The distinct non-empty subsets whose sum is at most 3 are: [1], [2], [3], and [1, 2].
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak