Mini-Max Sum

  • + 0 comments

    Problem is easy but 1 thing need to be considered is the number can be a big int. Golang code func miniMaxSum(arr []int32) { // Write your code here maxEle := arr[0] minEle := arr[0] sum := int64(0) for i := 0; i < len(arr); i ++ { sum += int64(arr[i]) if arr[i] > maxEle { maxEle = arr[i] } else { if arr[i] < minEle { minEle = arr[i] } } }

    fmt.Printf("%v %v", sum - int64(maxEle), sum - int64(minEle))
    

    }