We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Mini-Max Sum
- Discussions
Mini-Max Sum
Mini-Max Sum
Sort by
recency
|
340 Discussions
|
Please Login in order to post a comment
I've read multiple Java Solutions using Collections.sort on the array. I know it doesn't really matter for this problem where the array is always of size 5, but it makes more sense just to iterate through the array one time:
`
Hi, my code seems to be correct almost all the cases except one. the arr = [5, 5, 5, 5, 5], so I tried to account for the fact that the values might be the same (or at least attempted) and I am still struggling. Could someone please explain what it is I am doing wrong? Thanks in advance :) CODE:
def miniMaxSum(arr):
I achieved in O(n log n) because of the sort method.
def miniMaxSum(arr): a=sum(arr)-max(arr) b=sum(arr)-min(arr) return print(a,b)