Doubt in program

why did we take min value for int and exc
and what is the purpose of exc.

Hello @dhruvj797,

If the condition capacity >= wt[n-1] is false then, we should always return the value stored in exc. As, we are returning max(inc, exc) so, initializing inc with the smallest value would return exc = max(INT_MIN,exc).

purpose of exc:
For each item, there are two cases either we would include it (inc) or we would exclude it (exc). So, we need to calculate for both cases and return the maximum.

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.