You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The function accepts INTEGER_ARRAY arr as parameter.
*/
function miniMaxSum($arr)
{
//sort array ascending
sort($arr);
//sum every element on array
$total = array_sum($arr);
//in order to find minimum value, subtract the highest element from total value (highest element is the last element of array because of ascending sort we use earlier)
$min = $total - end($arr);
//in order to find maximum value, substract the lowest element from total value (lowest element is the first element of array because of ascending sort we use earlier)