MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / miniMaxSum

Function miniMaxSum

Hackerrank_problems/Mini-Max Sum/solution.py:3–11  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

1# Complete the miniMaxSum function below.
2
3def miniMaxSum(arr):
4 a=[] #empty list to add sum of numbers except the number of each element the list
5 for i in range(len(arr)):
6 if i==0: #checking for the empty list
7 a=[sum(arr)-arr[i]] #adding the first element in that empty list
8 else:
9 a.append(sum(arr)-arr[i]) #appending the sum for other elements
10
11 print("{} {}".format(min(a),max(a))) #printing the minimum of all the sums and maximum of all the sums
12
13
14

Callers 1

solution.pyFile · 0.85

Calls 3

sumFunction · 0.85
minFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected