Help with error

code: https://ide.codingblocks.com/s/449810
problem: https://leetcode.com/problems/ones-and-zeroes/

all test cases are not passing

the mistake I think I have made here is that I’m choosing exactly n + m elements whereas the question says to choose at most n + m elements

made some changes and it is passing a few more test cases: https://ide.codingblocks.com/s/449817

hello @raghav007

here in this problem u need to have atmost m 0’s and atmost n one ’ u r solving for exactly m and exaclty n case .

inside function there is no need of for loop.

solve(i,m,n) = include i th if satisfy condition and make call on solve(i+1,updatedM,updatedN)
or
exclude ith and make a call on solve(i+1,m,n).

pick max of these two cases.

how do I update m and n without a loop

For frequ3ncy u have to use loop.

I m talking about loop that is their in line 29.


please tell the mistake


this is the newer code please check this one instead

check now->

a) removed count from dp state
b) changed dp size(check constraints)

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.