My same code giving wa

this is the question

Hello @Muskan-Gupta-598128740703036, change you max value with Integer.MAX_VALUE as you have written Long.MAX_VALUE and later on inside the loop we are adding the no. into it due to which it is getting overflow.
Just change the value it will get accepted.
I hope it is clear to you. In case it is clear to you pls mark it as resolve and provide the rating as well as feedback so that we can improve ourselves.
In case there is still some confusion pls let me know, I will surely try to help you out.
Thanks :slight_smile:
Happy Coding !!

sir but long mei kabh add hoga?? bs compare krte waqt hi toh aayga

Pls consider this line here we are adding arr[i][1] to check but by overflowing it can give the negative value and hence the result will be WA.
dp[i][v]=Math.min(arr[i][1] + dp[i-1][v-arr[i][2]],dp[i][v]);