Tuesday, 19 September 2017

Chicken Stroganoff - Crock Pot
Source: RecipeZaar Rating: none
IngredientsServes: 6
1 lb boneless skinless chicken (frozen boneless skinless chicken breast)
10.5 oz cream of mushroom soup (fat-free)
16 oz fat free sour cream
1.25oz onion soup mix (dry)
Method
1 Put frozen chicken in bottom of crock pot.
2 Mix soup, sour cream, and onion soup mix.
3 Pour over chicken.
4 Cook on low for 7 hours (or high for 4 hours).
5 Serve over rice or noodles.

C# interview samples

    1. You are given any array of length n.You have to sort the array elements in decreasing order of their frequency.Use of Collections is not allowed.Write a function which sorts the element accordingly.    

    Example:     Input :[2,3,4,2,8,1,1,2]           Output:[2,2,2,1,1,3,4,8]

    Solution:

    var a = new[] {2, 3, 4, 2, 8, 1, 1, 2}; 
    Array.Sort(a); 
    var b = new int[a.Length,2]; 
    var k = 0; 
    int j; 
    for (var i = 0; i < a.Length; i++) 
       b[k,0] = a[i]; b[k,1] = 1; 
       for(j=i+1; j<a.Length; j++) 
          if (a[i] == a[j]) b[k,1]++; 
       i = i+b[k,1]-1; k++; 
    for(var i=0;i<k-1; i++) 
     for (j = i + 1; j < k; j++) { 
         if (b[i, 1] < b[j, 1]) 
        { var t1 = b[i, 0]; var t2 = b[i, 1]{}; 
           b[i, 0] = b[j, 0]; b[i, 1] = b[j, 1]; 
           b[j, 0] = t1; b[j, 1] = t2; 
        } 
    var result = new int[a.Length]; 
    j = 0; 
    for(var i=0; i<k; i++) 
         for (var l = 0; l < b[i, 1]; l++) 
         { 
             result[j++] = b[i, 0]; 
         }

      2. In given array find two element with the sum closest to 0. For example, input { 15, 5, -20, 30, -45 }. Output: 15, -20.


      int[] a = { 15, 5, -20, 30, -45 };
                  var pos = new int[a.Length];
                  var neg = new int[a.Length];
                  var i = 0;
                  var j = 0;
                  foreach (var el in a)
                  {
                      if (el >= 0) pos[i++] = el;
                      else neg[j++] = el;
                  }

                 // var pos = a.Where(e => e >= 0).ToArray();    //Linq if you want
                  //var neg = a.Where(e => e < 0).ToArray();

                  var diff = a.Max();
                  var p = pos[0];
                  var n = neg[0];

                  foreach (var po in pos)
                      foreach (var ne in neg)
                      {
                          var temp = Math.Abs(po + ne);
                          if (temp <= diff)
                          {
                              p = po;
                              n = ne;
                              diff = temp;
                          }
                      }
                  Console.WriteLine("Array: {0}", a);
                  Console.WriteLine("Diff: {0},  Positive: {1},  Negative: {2}", diff, p, n);