question:-https://hack.codingblocks.com/app/contests/1331/1255/problem
answer:-https://ide.codingblocks.com/s/265810
sir there is problem in optimizing space ,can we optimize using vector ,if we can use vector then why it shows error segmentation fault plz explain sir
Dp space optimization problem
@rajsharma96309
You can declare 2D vector like this.
vector<vector<int> > dp(n,vector<int>(n,-1));
your base case was wrong, I have corrected it. Please check
if(i>j)
{
// dp[i][j]=0;
return 0;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.