HELP!! DP knapsack space optimization 3d to 2d how??

Revision en1, by sridhar153999, 2020-02-29 15:20:28


i found this dp problem on leetcode (ones and zeros) ( i solved it using 3 states [position][no_of_zeros][no_of_ones] its giving me memory limit exceeded i saw some people using 2d state [no_of_zeros][no_of_ones] .i cant understand how they come up with their solution .help me explaining their 2 d concept. MY solution link solution although the time complexity of my code and thier code is same.

Tags 0/1 knapsack, #2d-dp, #3d-dp


  Rev. Lang. By When Δ Comment
en1 English sridhar153999 2020-02-29 15:20:28 593 Initial revision (published)