Skip to content

Instantly share code, notes, and snippets.

@codeperfectplus
Created September 16, 2023 12:51
Show Gist options
  • Save codeperfectplus/728b06be0fa6e129093149ef684cac08 to your computer and use it in GitHub Desktop.
Save codeperfectplus/728b06be0fa6e129093149ef684cac08 to your computer and use it in GitHub Desktop.
void miniMaxSum(vector<int> arr) {
long long min = LLONG_MAX , max = LLONG_MIN , sum ;
for(int i = 0 ;i < arr.size() ; ++i)
{
sum = 0;
for(int j = 0; j < arr.size() ; ++j)
{
if(i != j)
sum += arr[j];
}
if(sum > max)
max = sum;
if (sum < min)
min = sum;
}
cout << min << " " << max << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment