Having Problem with Constructor.


  • 0
    A

    Why cannot i initialize psum inside parameterized constructor NumArray

     public:     
    NumArray(const vector<int> nums)
          {         psum(nums.size()+3,0)
             //int x=nums.size();
             //psum(10,0) 
            //psum(x+1,0)
             partial_sum( nums.begin(), nums.end(), psum.begin()+1);
         }        
      int sumRange(int i, int j) 
    {        
     return psum[j+1] - psum[i];
         } 
    private:     
    vector<int> psum; 
    }; 
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.