Single test case wrong

See approach this problem as a backtracking problem…every array element has 2 choices it could either contribute to the sum or it could not contribute to the sum…your logic may work for smaller cases but for larger cases this approach doesn’t work…

In my approach i think i am doing the same once it contributes and if the sum exceeds i start removing the element from start. Also if i think like the way you told me to that means the elements are not necessarily contiguous which are contributing to the sum?

Subset means non continuous elements only…in subarray we consider continuous elements