I forgot to add this. Upper case, lower case characters are considered same. (Case insensitive ). We only need to consider A-Z or a-z, skip everything else.

@lokesh755 No, o(n) is of obviously impossible (but O(n) might be possible). What is "-ve"? Looks like a typo. Why do you make stuff hard to read? Finally, your idea doesn't work. You're not keeping the relative positions. Of course I should've just stopped reading your post at "o(n)", as that already told me that you don't know what you're doing.

int maxProduct(int *arr, int n){
int S = 0, S1 = 0, max = INT_MIN;
for(int i = 0; i < n; i++)
S += arr[i];
for(int i = 0; i < n-1; i ++){
S1 += arr[i];
int product = S1*(S-S1);
if(product > max)
max = product;
}
return max;
}