Skip to main content

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)
      List<long> a = new List<long>();
      int index=0;
      long minx,maxx;
      minx= long.MaxValue;
      maxx= long.MinValue;
      for(int i=0;i< arr.Count; i++){
             if(  a.Count == index){
                 a[index] =a[index]+ arr[i];
      }     index++;  
      }while (a.Count < arr.Count);
      foreachlong m in a){
          minx = Math.Min(minx,m);
          maxx = Math.Max(maxx,m);
      Console.WriteLine(minx+ " " +maxx);


Time Conversion

 The strings such as shown below, the function converts it into 24 hour pattern.

07:05:45PM to 19:05:45
12:40:22AM to 00:40:22

    public static string timeConversion(string s)
        string scope = s.Substring(s.Length-2);
         string timex = s.Substring(0,s.Length-2);
         string[] numbers =timex.Split(':');
         int hour = Convert.ToInt32(numbers[0]);
          hour = hour + (scope == "PM" ? 12 :0);
         return string.Format("{0}:{1}:{2}", hour.ToString("D2") ,numbers[1],numbers[2]);