I'm wondering if we have a matrix declared as vector<vector<int>> matrix
and we want to push back to the matrix another vector let's say vector<int> array = {1, 2, 3}
, what would be the time complexity of matrix.push_back(array)?
My guess would be O(n) because when we are appending to the matrix the array, all the elements from the array are copied and added separately, until we fill the the whole "row" in the matrix. I'm not really sure. I'm thinking it could be also O(1) beacause maybe cpp could be considering matrix.push_back(array) similar to array.push_back(5), which is clearly O(1). What do you think, guys?