Here’s the problem:
Here’s my solution:
It passes all the test cases except 2, and I am having quite a hard time figuring out where I went wrong.
I understand the other solutions(namely dp on 2 arrays or using the same array in different directions) but wanted to know what was wrong with this one.
I’d appreciate if someone could point the mistake out to me, or maybe give me a test case that the code fails.