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
|
946 Discussions
|
Please Login in order to post a comment
def miniMaxSum(arr): total_sum = sum(arr) min_val = min(arr) max_val = max(arr) min_sum = total_sum - max_val max_sum = total_sum - min_val print(min_sum, max_sum)
if name == 'main':
java
public static void miniMaxSum(List arr) { // Write your code here long sum = 0 ; for(int i=0; i< arr.size(); i++) { sum = sum + arr.get(i) ; } long max = 0; long min= sum; long current; for(int i=0; i< arr.size(); i++) { current = sum - arr.get(i) ; if(max < current) { max = current; } if(current < min) { min = current; }
so simple in py
python - why is this failing test 4?
why is this failing test 4? undefined
in C