Mini-Max Sum

  • + 0 comments
    def miniMaxSum(arr: Array[Int]) {
        var min: Long = 1000000000L
        var max: Long = 1L
        var total: Long = 0L
    
        for (i <- arr){
            val currValue = i.toLong
            if (currValue <= min){
                min = currValue
            }
            if (currValue >= max){
                max = currValue
            }
            total += currValue
        }
        println(s"`${total - max} $`{total - min}")
    }