HackerRank Mini-Max Sum Problem Solution
HackerRank Mini-Max Sum Problem Solution
HackerRank Mini-Max Sum Problem Solution
In this HackerRank Mini-Max Sum problem solution Given five positive integers, find the
minimum and maximum values that can be calculated by summing exactly four of the
five integers. Then print the respective minimum and maximum values as a single line
of two space-separated long integers.
Search
Subscribe To Channel
Example
Programmingoneonone
The minimum sum is 1+3+5+7 = 16 and the maximum sum is 3+5+7+9 = 24. The
function prints
Learn DSA For Free
16 24
Function Description
CLOSE ADS CLOSE ADS
Print two space-separated integers on one line: the minimum sum and the maximum
sum of of elements.
Input Format
Constraints
Output Format
Print two space-separated long integers denoting the respective minimum and maximum
values that can be calculated by summing exactly four of the five integers. (The output
can be greater than a 32 bit integer.)
HackerRank Diagonal
Difference problem solution
March 23, 2021
Crafted with by TemplatesYard | Distributed by Blogger
import math
import os
import random
import re
import sys
print(hold[0],hold[-1])
if __name__ == '__main__':
arr = list(map(int, input().rstrip().split()))
miniMaxSum(arr)
CLOSE ADS CLOSE ADS
lld allsum = 0;
lld MN = LLONG_MAX, MX = LLONG_MIN;
int main() {
int a[5];
long sum=0;
for(int i=0;i<5;i++){
scanf("%d",a+i);
sum+=a[i];
}
int min=a[0];
int max=a[0];
for(int i=1;i<5;i++){
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("%ld %ld",sum-max,sum-min);
return 0;
CLOSE ADS CLOSE ADS
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});
CLOSE ADS CLOSE ADS
Facebook Twitter
Post a Comment
1 Comments
GAJANAN KULKARNI
January 20, 2022 at 10:47 PM
Reply Delete
Replies
Reply
Add comment
To leave a comment, click the button below to sign in with Blogger.