I created a 3d dp of size 51x51xn in c++:
vector<vector<vector<int>>>dp(51,vector<vector<int>>(51,vector<int>(n,-1)));
This code gives memory limit exceeded
I changed it to nx51x51 and it gives accepted
vector<vector<vector<int>>>dp(n,vector<vector<int>>(51,vector<int>(51,-1)));
But both takes same memory.
What is wrong in first way??
New contributor
kinshuk_khare is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.