Last question in bitmasking


what is the problem with this code?

problem:https://www.spoj.com/problems/SUBSUMS/

Hey Hritam, actually the code by Prateek Sir has few bugs:

  1. j++ should be outside for loop(as you ignore elements whose corresponding bit is 0)
  2. an edge case (n=1) gives segmentation fault.
  3. for n<=17, you may directly generate all subset sums and check if it lies within given range.
    Try rectifying these

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.