If the sum is less than or equal to k , then find if there is a prefix array having sum that needs to be added to the current sum to make its value greater than k . If yes , then compare the length of updated subarray with maximum length found so far .
else { int ind = findInd ( preSum , n , sum - k - 1 ) ; if ( ind != -1 && minInd [ ind ] < i ) maxlen = max ( maxlen , i - minInd [ ind ] ) ; } } return maxlen ; }