Kindly tell me the expected time complexity. i am able to do it in O(m*n)
I have a doubt regarding complexities
Then good
This is expected time complexity
You should have done it using dp
space complexity bhi O(m*n) hai… tle aa rha hai
although Space complexity ko O(max(m,n)) kr sakta hu but … tle to time complexity se aata hai na
run error aa rha hai srry… then maybe space complexity ki vahaj se aa rha ho
NO,
due to space complexity you will get MLE (Memory Limit Exceeded)
this may be because you have not define dp array of appropriate size
check out my code below
Reference Code