Relative Content

Tag Archive for c++vectordynamic-programming

3d vector giving memory limit exceeded but swapping 2 numbers gives accepted even though memory used is same

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?? c++ vector dynamic-programming New contributor kinshuk_khare is a new contributor to this site. Take care in asking […]