Print all strings corresponding to elements in a subarray with maximum absolute sum

  
#include
using namespace std;
  

void maximumAbsSum(pair* arr,
                   int N)
{
    int start = 0, end = 0, res = 0,
        negIndex = 0, posIndex = 0,
        negPrefix = 0, posPrefix = 0;
  
    
    for (int i = 0; i < N; i++) {            if (arr[i].second < 0) {                                                                       if (res < abs(arr[i].second                           + negPrefix)) {                    res = abs(arr[i].second                           + negPrefix);                 start = negIndex;                 end = i;             }         }            else {                                          if (res < abs(arr[i].second                           + posPrefix)) {                    res = abs(arr[i].second                           + posPrefix);                 start = posIndex;                 end = i;             }         }                                       if (negPrefix + arr[i].second > 0) {
  
            negPrefix = 0;
            negIndex = i + 1;
        }
  
        
        
        else {
  
            negPrefix += arr[i].second;
        }
  
        
        
        if (posPrefix + arr[i].second >= 0) {
  
            posPrefix += arr[i].second;
        }
  
        
        
        
        else {
  
            posPrefix = 0;
            posIndex = i + 1;
        }
    }
  
    
    for (int i = start; i