runtime error: reference binding to null pointer of type 'int' (stl_vector.h)

I'm getting this Error , Anyone please Explain , What I am Missing , I was not able to figure out what is wrong in this ?

Char 9: runtime error: reference binding to null pointer of type 'int' (stl_vector.h)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:9

'''
class Solution {
public:

int minMaxGame(vector<int>& nums) {
    
     int n = nums.size();
   
    int maxx = 0;
    int minn = 0;
    
    vector<int> newNum(n/2,0);
    
     // Base Condition 
    if(n == 1){
        cout << "Hii";
        // cout << newNum[0];
        return newNum[0];
    }
    
    // Condition for given Problem statement
    for(int i =0; i < n/2; i++){
        
        if( i%2 == 0 ){
            minn = min(nums[2*i] , nums[2*i+1]);
            newNum.push_back(minn);
            cout << "minn : "<<minn << " ";
            
        }else{
            maxx = max(nums[2*i] , nums[2*i+1]);
            newNum.push_back(maxx);
            cout << "maxx : "<<maxx << "| ";
            
        }
    }
     cout << endl;
    
    
   
   
    //Recusion
     minMaxGame(newNum);
    
    return newNum[0];
    
   
}

};
'''

Comments (1)