Runtime Error: reference binding to null pointer of type 'value_type'


  • 0
    K

    '''
    class Solution {
    public:
    int pivotIndex(vector<int>& nums) {
    int n = nums.size();
    int left_sum = nums[0];
    int right_sum = nums[n-1];
    int left_index = 0;
    int right_index = n-1;

        while(left_index != right_index){
            if(left_sum > right_sum){
                right_index--;
                right_sum += nums[right_index];
            }
            if(left_sum < right_sum){
                left_index++;
                left_sum += nums[left_index];
            }
            if(left_sum == right_sum){
                return nums[left_index];
            }
        }
        return -1;
        
    }
    

    };
    '''
    I keep getting the runtime error
    Runtime Error Message: reference binding to null pointer of type 'value_type'
    Last executed input : [ ]
    Can someone please help me


Log in to reply
 

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