O(n^3) not getting selected


#1

Comment body goes here
int Solution::solve(vector<vector > &A) {
int rows = A.size();
int cols = A[0].size();

int L=0,R=0;
int max_L=0,max_R = 0;
int max_U=0,max_D=0;
int max_sum=INT_MIN;
int arr[rows];

for(L=0 ; L<cols ; L++){
    for(int i=0;i<rows;i++){
                arr[i] = 0;
    }
    for(R=L ; R<cols ; R++){
        
       
        for(int i=0;i<rows;i++){
            arr[i] += A[i][R];
        }
        
        //APPLYING KADANE ON ARR
        int max_so_far = INT_MIN, max_ending_here = 0, start =0, end = 0, s=0; 
      
        for (int i=0; i< rows; i++ ) 
        { 
            max_ending_here += arr[i]; 
      
            if (max_so_far < max_ending_here) 
            { 
                max_so_far = max_ending_here; 
                start = s; 
                end = i; 
            } 
      
            if (max_ending_here < 0) 
            { 
                max_ending_here = 0; 
                s = i + 1; 
            } 
        } 
        if(max_so_far>max_sum){
            max_sum = max_so_far;
            max_L = L;
            max_R = R;
            max_U = start;
            max_D = end;
        }
        // end of kadane
        
    }
}
return max_sum;

}
.