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.
publicstaticvoidminiMaxSum(List<Integer>arr){// Write your code here//converting to normal arrayintn=arr.size();longarray[]=newlong[n];for(inti=0;i<n;i++){array[i]=arr.get(i);}//bubble sortfor(inti=0;i<array.length-1;i++){for(intj=0;j<array.length-1-i;j++){if(array[j]>array[j+1]){longtemp=array[j];array[j]=array[j+1];array[j+1]=temp;}}}longminSum=0,maxSum=0;for(inti=0;i<array.length-1;i++){minSum=array[i]+minSum;}for(inti=1;i<array.length;i++){maxSum=array[i]+maxSum;}System.out.print(minSum+" "+maxSum);}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 5
You are viewing a single comment's thread. Return to all comments →