Sort by

recency

|

5949 Discussions

|

  • + 0 comments

    public static void miniMaxSum(List arr) { // Write your code here long minimum = arr.get(0); long maximum = arr.get(0);

        long sum = 0;
    
        for(Integer element : arr) {
            if(minimum > element) {
                minimum = element;
            }
            if(maximum < element) {
                maximum = element;
            }
            sum+=element;
        }
        System.out.println((sum - maximum) + " " + (sum - minimum)) ;
    
    }
    
  • + 0 comments
    def miniMaxSum(arr):
        mi = ma = sum(arr[1:])
        for index in range(1, 5):
            current_sum = sum(arr[0:index] + arr[index + 1:])
            if current_sum < mi:
                mi = current_sum
            if current_sum > ma:
                ma = current_sum
        print(mi, ma)
    
  • + 0 comments

    Don't make want to make code is too coplicated to see for the beginers.

    //Just on default package - collections

    Collections.sort(arr); long Max=0L; long Min=0L; for(int A =0;A-1;B--){ if(B!=arr.size()-1){ Min=Min+arr.get(B); } } System.out.print(Min + " " +Max);

  • + 0 comments

    Collections.sort(arr);

    long Max=0L;
    long Min=0L;
    
    for(int A =0;A<arr.size();A++){
        if(A!=0){
            Max=Max+arr.get(A);
        }
    }
    
    for(int B = arr.size()-1;B>-1;B--){
        if(B!=arr.size()-1){
            Min=Min+arr.get(B);
        }
    }
    
    System.out.print(Min + " " +Max);
    
  • + 0 comments

    Python 3 solution:

        arr_sort = sorted(arr)
        print(f'{sum(arr_sort[0:4])} {sum(arr_sort[1:])}')