We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
voidminiMaxSum(intarr_count,int*arr){/* long int because the output more than 32 bit so we will deal with (long int) 64 bit*/longintmaxN=arr[0],/* max number in array*/minN=arr[0],/* min number in array*/sum=0;/* the sum of all elements */for(inti=0;i<arr_count;i++){if(maxN<arr[i])maxN=arr[i];/* max number in array */if(minN>arr[i])minN=arr[i];/* min number in array */sum+=arr[i];/* summing */}/* the lowest value is sum-maxValue, the highest value is sum-minValue*/printf("%ld %ld\n",sum-maxN,sum-minN);}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
in C