Recursive solution for the given problem is giving MLE.Why?


is a recursive solution acceptable for this problem ?


recursive solution is acceptable!!
but it seems that you use vector v in defination of your recusive function .replace it by
const vector& v ans your solution will not get MLE.


@gargsakshi, I replaced vector A with const vector &A and now I am getting runtime error.
Any suggestions?