Category : indexing

Problem Write a function: vector<int> solution(vector<int> &P, vector<int> &Q); that given a zero-indexed, tensor P which is linearized consisting of M integers and a zero-indexed array Q consisting of N integers representing the size of each dimension of the tensor. It returns an array of integers where each element of the output tensor is the ..

Read more

So I have a 2d array of vectors, and apparently changing the element at an index can also change the one above it. Here is the code that is causing me issues: /// Initialization std::vector<int> x_array; std::vector<int> y_xarray[2000][2]; int ymin=200; //Problematic code x_array.clear(); //x_array is an std::vector<int> x_array.push_back(594); y_xarray[251-ymin][0]=x_array; //y_xarray is a 2d array of ..

Read more