title: Frequent Element Array 1
signature: function frequentElementArray1(arr: Array<number>, n: number): number {
source_py: def frequent_element_array_1(arr, n):
      Hash = dict()
      for i in range(n):
          if (arr[i] in Hash.keys()):
              Hash[arr[i]] += 1
          else:
              Hash[arr[i]] = 1
      max_count = 0
      res = (- 1)
      for i in Hash:
          if (max_count < Hash[i]):
              res = i
              max_count = Hash[i]
      return res
source_cpp: int frequent_element_array_1(vector<int> arr, int n) {
    unordered_map < int, int > hash;
    for ( int i = 0;
    i < n;
    i ++ ) hash [ arr [ i ] ] ++;
    int max_count = 0, res = - 1;
    for ( auto i : hash ) {
      if ( max_count < i . second ) {
        res = i . first;
        max_count = i . second;
      }
    }
    return res;
  }
question_info.test_list: [{"idx": 0, "outputs": 9, "inputs": {"arr": [3, 5, 7, 9, 9, 10, 11, 15, 19, 19, 29, 31, 34, 34, 35, 37, 41, 43, 45, 47, 51, 51, 55, 57, 59, 61, 65, 67, 73, 76, 77, 77, 80, 83, 83, 84, 84, 92, 94], "n": 24}}, {"idx": 1, "outputs": -38, "inputs": {"arr": [14, -38, -84, 24, 82, -68, 60, 2, -22, 54, 90, 90, -38, -8, -72, 68, 50, 54, -32, -66, -10, -70, -28, 18, 58, -54, -30, 60, -24, -48, 22, 32, -18, 2, -64, -56, 70, -92, -38, -70, 22, -36, -64], "n": 28}}, {"idx": 2, "outputs": 1, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 18}}, {"idx": 3, "outputs": 82, "inputs": {"arr": [76, 18, 41, 46, 34, 41, 56, 76, 14, 82, 51, 87, 1, 92, 9, 2, 68, 82, 43, 98, 88, 62, 84, 25, 7, 87, 37, 7, 55, 98, 60, 99, 92, 56, 17, 82, 28, 43, 40, 1, 99, 79, 38, 75, 84, 61, 21, 11], "n": 37}}, {"idx": 4, "outputs": -86, "inputs": {"arr": [-92, -86, -86, -84, -70, -68, -68, -66, -62, -52, -52, -50, -48, -38, -22, -14, -6, 4, 8, 10, 10, 16, 22, 36, 38, 40, 50, 50, 70, 78, 80, 86, 96, 96, 98], "n": 21}}, {"idx": 5, "outputs": 1, "inputs": {"arr": [1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0], "n": 18}}, {"idx": 6, "outputs": 3, "inputs": {"arr": [3, 53, 56, 57, 66, 73, 76, 94, 97], "n": 8}}, {"idx": 7, "outputs": 12, "inputs": {"arr": [12, 60, -94, 92], "n": 3}}, {"idx": 8, "outputs": 0, "inputs": {"arr": [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], "n": 21}}, {"idx": 9, "outputs": 73, "inputs": {"arr": [95, 93, 82, 73, 61, 24, 73, 21, 47, 91, 48, 42, 76, 12, 89, 21, 3, 30, 5, 49, 26, 54, 16, 70, 50, 21, 58, 36, 16], "n": 25}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(arr: Array<number>, n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver([3, 5, 7, 9, 9, 10, 11, 15, 19, 19, 29, 31, 34, 34, 35, 37, 41, 43, 45, 47, 51, 51, 55, 57, 59, 61, 65, 67, 73, 76, 77, 77, 80, 83, 83, 84, 84, 92, 94], 24, 9);
    console.log(`TEST-0...${result}`);
  
    result = driver([14, -38, -84, 24, 82, -68, 60, 2, -22, 54, 90, 90, -38, -8, -72, 68, 50, 54, -32, -66, -10, -70, -28, 18, 58, -54, -30, 60, -24, -48, 22, 32, -18, 2, -64, -56, 70, -92, -38, -70, 22, -36, -64], 28, -38);
    console.log(`TEST-1...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 18, 1);
    console.log(`TEST-2...${result}`);
  
    result = driver([76, 18, 41, 46, 34, 41, 56, 76, 14, 82, 51, 87, 1, 92, 9, 2, 68, 82, 43, 98, 88, 62, 84, 25, 7, 87, 37, 7, 55, 98, 60, 99, 92, 56, 17, 82, 28, 43, 40, 1, 99, 79, 38, 75, 84, 61, 21, 11], 37, 82);
    console.log(`TEST-3...${result}`);
  
    result = driver([-92, -86, -86, -84, -70, -68, -68, -66, -62, -52, -52, -50, -48, -38, -22, -14, -6, 4, 8, 10, 10, 16, 22, 36, 38, 40, 50, 50, 70, 78, 80, 86, 96, 96, 98], 21, -86);
    console.log(`TEST-4...${result}`);
  
    result = driver([1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0], 18, 1);
    console.log(`TEST-5...${result}`);
  
    result = driver([3, 53, 56, 57, 66, 73, 76, 94, 97], 8, 3);
    console.log(`TEST-6...${result}`);
  
    result = driver([12, 60, -94, 92], 3, 12);
    console.log(`TEST-7...${result}`);
  
    result = driver([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], 21, 0);
    console.log(`TEST-8...${result}`);
  
    result = driver([95, 93, 82, 73, 61, 24, 73, 21, 47, 91, 48, 42, 76, 12, 89, 21, 3, 30, 5, 49, 26, 54, 16, 70, 50, 21, 58, 36, 16], 25, 73);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: frequentElementArray1
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js