title: Minimum Number Subsets Distinct Elements
signature: int minimumNumberSubsetsDistinctElements(vector<int> ar, int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(vector<int> ar, int n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(ar, n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver({1, 2, 5, 8, 16, 21, 21, 22, 23, 26, 26, 27, 27, 29, 31, 33, 36, 37, 37, 38, 42, 45, 47, 50, 57, 58, 60, 60, 62, 63, 66, 66, 76, 84, 84, 88, 96, 99}, 25, 1); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver({-96, -96, -94, -94, -82, -82, -62, -60, -46, -46, -38, -36, -36, -30, -24, -22, -18, -14, -10, 2, 4, 4, 4, 8, 8, 12, 24, 34, 46, 50, 52, 70, 78, 78, 80, 80, 82, 82, 82, 86, 92, 94}, 35, 2); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 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}, 34, 27); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver({16, 38, 38, 41, 47, 48, 48, 48, 49, 62, 84, 92, 99}, 6, 1); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver({-88, -64, -40, -38, -38, -16, 16, 20, 28, 40, 56, 58, 60, 68, 74, 92}, 12, 1); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 0, 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}, 29, 22); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver({14, 24, 82, 87, 95}, 3, 1); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver({-90, -88, -84, -80, -80, -76, -68, -64, -58, -58, -58, -46, -40, -34, -18, -14, -10, 2, 2, 4, 8, 12, 14, 22, 40, 40, 46, 50, 52, 62, 62, 64, 68, 76, 90, 94}, 34, 1); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 1, 1, 1}, 3, 1); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver({5, 6, 17, 41, 43, 68, 68, 86, 89, 90}, 7, 1); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def minimum_number_subsets_distinct_elements(ar, n):
      res = 0
      ar.sort()
      for i in range(0, n):
          count = 1
          for i in range((n - 1)):
              if (ar[i] == ar[(i + 1)]):
                  count += 1
              else:
                  break
          res = max(res, count)
      return res
source_cpp: int minimum_number_subsets_distinct_elements(vector<int> ar, int n) {
    int res = 0;
    sort(ar.begin(), ar.end());
    for ( int i = 0;
    i < n;
    i ++ ) {
      int count = 1;
      for (;
      i < n - 1;
      i ++ ) {
        if ( ar [ i ] == ar [ i + 1 ] ) count ++;
        else break;
      }
      res = max ( res, count );
    }
    return res;
  }