#include <vector>
using namespace std;
class NumArray
{
public:
NumArray(vector<int>& nums)
: nums(nums)
, length(nums.size())
{
vector< vector<int> > tmp(length, vector<int> (length, NULL));
this->lookup = tmp;
}
private:
vector<int>& nums;
vector< vector<int> > lookup;
int length;
};
I got an inefficient way to initialize the vector lookup by constructing vector tmp first, but there should be a method initialize lookup through initializer list explicitly. Like
public:
NumArray(vector<int>& nums)
: nums(nums)
, length(nums.size())
, lookup(length, vector<int> (length, NULL))
{
}
But this doesn't work. Is there any way to fix it?