title: Distributing Items Person Cannot Take Two Items Type
signature: class Solution {
  
      public Boolean distributingItemsPersonCannotTakeTwoItemsType(ArrayList<Integer> arr, Integer n, Integer k) {
source_py: def distributing_items_person_cannot_take_two_items_type(arr, n, k):
      for i in range(n):
          count = 0
          for j in range(n):
              if (arr[j] == arr[i]):
                  count += 1
              if (count > (2 * k)):
                  return False
      return True
source_cpp: bool distributing_items_person_cannot_take_two_items_type(vector<int> arr, int n, int k) {
    int count;
    for ( int i = 0;
    i < n;
    i ++ ) {
      count = 0;
      for ( int j = 0;
      j < n;
      j ++ ) {
        if ( arr [ j ] == arr [ i ] ) count ++;
        if ( count > 2 * k ) return false;
      }
    }
    return true;
  }
question_info.extension: java
question_info.entry_fn_name: distributingItemsPersonCannotTakeTwoItemsType
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": true, "inputs": {"arr": [1, 1, 2, 3, 1], "n": 5, "k": 2}}, {"idx": 1, "outputs": true, "inputs": {"arr": [2, 3, 3, 5, 3, 3], "n": 6, "k": 2}}, {"idx": 2, "outputs": true, "inputs": {"arr": [0, 0, 1, 1, 1], "n": 2, "k": 1}}, {"idx": 3, "outputs": true, "inputs": {"arr": [7, 60, 78, 91, 80, 75, 85, 21, 41, 63, 1, 84, 69, 13, 94, 25, 54, 54, 52, 68, 53, 35, 17, 37, 98, 27, 2, 31], "n": 24, "k": 2}}, {"idx": 4, "outputs": true, "inputs": {"arr": [-96, -94, -82, -80, -78, -66, -36, -24, -18, -12, -2, -2, 6, 8, 10, 12, 36, 38, 42, 58, 64, 68, 82, 84, 86, 88, 94], "n": 24, "k": 3}}, {"idx": 5, "outputs": false, "inputs": {"arr": [0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0], "n": 34, "k": 2}}, {"idx": 6, "outputs": true, "inputs": {"arr": [16, 19, 25, 25, 32, 37, 48, 59, 60, 60, 71, 74, 77, 81, 91, 94], "n": 10, "k": 8}}, {"idx": 7, "outputs": true, "inputs": {"arr": [-62, -94, 72, -22, 86, -80, 64, 98, -82, -50, 12, -4, 56, 46, -80, 2, -86, -44, -26, 68, -94, -82, 74, 26, 94, 40, 50, -40, -42, -10], "n": 20, "k": 4}}, {"idx": 8, "outputs": false, "inputs": {"arr": [0, 0, 0, 0, 0, 1, 1, 1], "n": 5, "k": 2}}, {"idx": 9, "outputs": true, "inputs": {"arr": [83, 57, 2, 47, 70, 22, 49, 51, 25, 57, 32, 7, 8, 99, 6, 86, 24, 79, 42, 43, 1, 24, 68, 11, 24, 12, 43, 40, 14, 45, 11, 46, 12, 80, 66], "n": 21, "k": 33}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> arr, Integer n, Integer k, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(arr, n, k,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 1, 2, 3, 1)), 5, 2, true);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 3, 3, 5, 3, 3)), 6, 2, true);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 1, 1, 1)), 2, 1, true);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(7, 60, 78, 91, 80, 75, 85, 21, 41, 63, 1, 84, 69, 13, 94, 25, 54, 54, 52, 68, 53, 35, 17, 37, 98, 27, 2, 31)), 24, 2, true);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-96, -94, -82, -80, -78, -66, -36, -24, -18, -12, -2, -2, 6, 8, 10, 12, 36, 38, 42, 58, 64, 68, 82, 84, 86, 88, 94)), 24, 3, true);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0)), 34, 2, false);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(16, 19, 25, 25, 32, 37, 48, 59, 60, 60, 71, 74, 77, 81, 91, 94)), 10, 8, true);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-62, -94, 72, -22, 86, -80, 64, 98, -82, -50, 12, -4, 56, 46, -80, 2, -86, -44, -26, 68, -94, -82, 74, 26, 94, 40, 50, -40, -42, -10)), 20, 4, true);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 1, 1, 1)), 5, 2, false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(83, 57, 2, 47, 70, 22, 49, 51, 25, 57, 32, 7, 8, 99, 6, 86, 24, 79, 42, 43, 1, 24, 68, 11, 24, 12, 43, 40, 14, 45, 11, 46, 12, 80, 66)), 21, 33, true);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> arr, Integer n, Integer k, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(arr, n, k),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__