#vector of vectors?

11 messages · Page 1 of 1 (latest)

wary veldt
#

can anybody tell me what does this do?

vector<vector<int>> dp(n,vector<int>(target+1,0));
mint coralBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

surreal venture
#

On mobile so I'll check it out better in a bit. A vector of a vector is basically a 2 dimensional array.

You push vectors of ints in the vectors of vectors. Last time I used it was for a grid, it made it easy to access elements with x and y coords. For example: grid[x][y]

abstract ridge
#

The inner vector makes a vector with target + 1 ints of value 0 and the outer vector puts n of those into dp.

#

So you sort of end with an n*target+1 matrix filled with 0s.

wary veldt
#

so basically it uses the first n to declare for the outer vector the amount of vectors of size target+1 it has ( so first constructor for the outer declaration and the second is the size of the inner vector declared)

#

if anybody can confirm this im marking it as solved

wary veldt
wary veldt
#

!solved