title: Difference Between Highest And Least Frequencies In An Array
signature: function difference_between_highest_and_least_frequencies_in_an_array(arr, n)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(arr, n, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver([5, 15, 19, 22, 28, 29, 39, 46, 46, 49, 51, 55, 62, 69, 72, 72, 72, 74, 79, 92, 92, 93, 95, 96], 15, 1);
      @printf("TEST-0...%s\n",result);
      
      result = driver([-92, -92, -78, -74, -70, -66, -60, -54, -50, -48, -34, -32, -26, -24, -22, -14, -10, -10, -6, 2, 4, 6, 12, 18, 34, 42, 52, 56, 76, 92, 92], 30, 1);
      @printf("TEST-1...%s\n",result);
      
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 24, 0);
      @printf("TEST-2...%s\n",result);
      
      result = driver([1, 5, 13, 17, 21, 22, 25, 26, 29, 29, 31, 32, 35, 38, 40, 46, 48, 48, 49, 53, 54, 59, 61, 65, 65, 66, 73, 79, 81, 83, 92, 92, 93, 96, 97, 98], 29, 1);
      @printf("TEST-3...%s\n",result);
      
      result = driver([-70, -34, -32, -30, -14, 80, 86, 90], 4, 0);
      @printf("TEST-4...%s\n",result);
      
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 23, 0);
      @printf("TEST-5...%s\n",result);
      
      result = driver([9], 0, 0);
      @printf("TEST-6...%s\n",result);
      
      result = driver([10, 42, 70, 94], 2, 0);
      @printf("TEST-7...%s\n",result);
      
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 24, 0);
      @printf("TEST-8...%s\n",result);
      
      result = driver([3, 4, 7, 8, 10, 15, 15, 17, 22, 26, 49, 55, 60, 64, 76, 79, 80, 84, 90, 92, 95, 96], 20, 1);
      @printf("TEST-9...%s\n",result);
      
  end
  
  main()
source_py: def difference_between_highest_and_least_frequencies_in_an_array(arr, n):
      arr.sort()
      count = 0
      max_count = 0
      min_count = n
      for i in range(0, (n - 1)):
          if (arr[i] == arr[(i + 1)]):
              count += 1
              continue
          else:
              max_count = max(max_count, count)
              min_count = min(min_count, count)
              count = 0
      return (max_count - min_count)
source_cpp: int difference_between_highest_and_least_frequencies_in_an_array(vector<int> arr, int n) {
    sort(arr.begin(), arr.end());
    int count = 0, max_count = 0, min_count = n;
    for ( int i = 0;
    i < ( n - 1 );
    i ++ ) {
      if ( arr [ i ] == arr [ i + 1 ] ) {
        count += 1;
        continue;
      }
      else {
        max_count = max ( max_count, count );
        min_count = min ( min_count, count );
        count = 0;
      }
    }
    return ( max_count - min_count );
  }