Why my code is not working?

All test cases are failing

Let me just give you a hint and you will then be able to fix your code yourself .
Suppose you intially chose the op2 and the call of op2 will increase the value of i from 0 to 1 and the count will still remain 0 .

So when you check the base case it returns true everytime without even selecting any of the elements in the array .

I would suggest you to handle the empty subset case by using a bool variable in function attributes , instead of i and cnt.
The one time you use op1 you have added a number in the subset so make that bool variable as true otherwise let it be . so when you finally find a subset check if the subset has a number or not using the bool variable .

If the bool is true : you have an element
else you don’t have any element in your subset .

I hope you get my point . Have a nice day :blush:
If this helped you in solving your query please mark it as resolved and rate me accordingly .

Hi @ankitlenka26 I followed this approach but still not able to solve this. Please check this!

Sure @18bcs036 . send me the link latest code you have written for this question

@ankitlenka26 here is the link https://ide.codingblocks.com/s/317542?_ga=2.90764250.1193643032.1597411682-882294266.1559977433

@18bcs036 add an << endl after your "No" otherwise the entire code is correct . xD you forgot just a small thing . :sweat_smile:

@18bcs036 also check your inbox for another way (almost similiar) way to do the same quesion
If your doubt is now resolved , mark it resolved and rate me accordingly . :slight_smile:

1 Like

Thanks @ankitlenka26 it’s done. :slight_smile: Thanks for your efforts!

1 Like