I am porting a JavaScript code to C++ .
Pseudo code :
if n = 1 then APPEND(orders, order)
JavaScript(order and orders are arrays) :
var order = new array();
var orders = new array();
//....
if (n == 1)
{
orders[orders.length] = order.slice(); // append copy
}
I am using vectors instead of array in C++ .
The C++ code i think should be just :
vector<int> order;
vector<vector<int> > orders;
//.....
orders.push_back(order)
Is this code correct for the above psudeo and javascript code ?
You have a condition
n == 1I don’t know why you have skipped that in your C++ implementation.in comments you said you are using
slice()to make a copy of original list so you do also need to do the same in your C++ implementation.