I am getting wrong answer in recursion tree(dry run)

I am getting 120 as my answer instead of 140 in this question when I tried doing the dry run.
I am also attaching the photo of the dry run.

Hi Sachita, share the test case as well for which you are doing dry run.

N = 4 C = 7 price = [40, 20, 35, 100] weight = [1, 2, 3, 5]

it is the same test case as shown in the video

Please reply I have shared the test case @Mayank MITTAL

Sachita you have to consider both cases -

  1. pick current object (if you can)
  2. ignore current object (even if you can pick it).
    So this way optimal answer will be picking first object, then ignoring second and third objects and finally picking last object.

can you send the picture of the dry run of the approach that you are talking about?

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.