Stack Overflow Asked by Bharti Jha on January 30, 2021
I have an array of positive integers {a1, a2, …., an}, and I want to count all possible subsets of the array which satisfy the following condition:
sum>=k
for eg .
i have an array [1,2,3,4]
and k = 4
so the subset will be {4}
and {3,2}
so the answer will be two .
Note that repetition of elements are not allowed means we can’t consider an element more than one time in our subset .
This is what i tried till now but getting wrong answer
if (arr - 1] >= k):
return isSubsetSum(arr - 1, k)
return isSubsetSum(
arrn-1, k) or isSubsetSum(
arrn-1, k-arr-1])
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP