My code: https://pastebin.com/XbyR6Das
I am getting the correct answer for almost all test cases but it's failing for larger test cases. Can someone explain why this is happening? Also, there is some weird behaviour I'm noticing when I run this code on my machine in sublime text. For larger testcases (when
n2==100), the output is changing if I increase the size of
dp array from
dp. Is this because I am using excess memory or is there some other reason?