Mini-Max Sum

  • + 0 comments

    so simple in py

    def sumMethod(idx,arr):
        sum = 0
        for idxs in range(len(arr)):
            if idxs ==idx:
                continue
            record = arr[idxs]
            sum+=record
        return sum
    
    def miniMaxSum(arr):
        # Write your code here
        res = []
        for idx in range(len(arr)):
            sumRecord = sumMethod(idx,arr)
            res.append(sumRecord)
        res.sort()
        max = res[len(res)-1]
        min = res[0]
        print(min,max)
        return