Skip to main content

Posts

Showing posts from October, 2021

Solved some problems

Mini-Max Sum   Given one array and the rule is create another array using the given arrays value. On each item of new array is the sum of the rest items of the given array except for the item of the same index comparing two arrays.   public   static   void  miniMaxSum(List< int > arr)     {         arr.Sort();       List< long > a =  new  List< long >();        int  index= 0 ;        long  minx,maxx;       minx=  long .MaxValue;       maxx=  long .MinValue;        do {                          for ( int  i= 0 ;i< arr.Count; i++){                          if (  a.Count == index){                  a.Add( 0 );              }               if (i!=index)              {                  a[index] =a[index]+ arr[i];              }                                    }     index++;         } while  (a.Count < arr.Count);               foreach (  long  m  in  a){            //Console.WriteLine(m);           minx = Math.Min(minx,m);           maxx = Math.Max(maxx,m);