title: First Element Occurring K Times Array
signature: first_element_occurring_k_times_array <- function(arr, n, k) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, k, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n, k), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(2L, 3L, 4L, 4L, 7L, 18L, 20L, 23L, 27L, 30L, 31L, 31L, 32L, 35L, 36L, 43L, 45L, 46L, 49L, 50L, 53L, 55L, 59L, 60L, 64L, 64L, 65L, 68L, 78L, 80L, 80L, 85L, 95L), 30L, 2L, 
          4L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-26L, 32L, 36L, 6L, 64L, 24L, -28L, 96L), 6L, 3L, 
          -1L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 15L, 7L, 
          -1L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(38L, 40L, 43L, 70L, 20L, 40L, 95L, 96L, 81L, 82L), 9L, 1L, 
          38L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-68L, -8L, -8L, 16L, 24L, 54L), 3L, 2L, 
          -8L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 1L), 6L, 4L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(13L, 18L, 19L, 28L, 31L, 34L, 49L, 49L, 53L, 57L, 58L, 62L, 75L, 76L, 77L, 78L, 80L, 84L, 84L, 85L, 87L, 91L, 98L, 99L), 20L, 2L, 
          49L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-4L, 24L, -86L, -84L, 30L, -16L, 12L, -92L, -68L, 22L), 6L, 5L, 
          -1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L), 8L, 10L, 
          -1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(55L, 44L, 75L, 97L, 25L, 65L, 76L, 53L, 20L, 78L, 25L, 59L, 61L, 29L, 81L, 35L, 15L, 78L, 41L, 44L, 31L, 33L, 39L, 93L, 26L, 67L), 23L, 20L, 
          -1L
      )))
  
  }
  
  main()
source_py: def first_element_occurring_k_times_array(arr, n, k):
      count_map = {
          
      }
      for i in range(0, n):
          if (arr[i] in count_map.keys()):
              count_map[arr[i]] += 1
          else:
              count_map[arr[i]] = 1
          i += 1
      for i in range(0, n):
          if (count_map[arr[i]] == k):
              return arr[i]
          i += 1
      return (- 1)
source_cpp: int first_element_occurring_k_times_array(vector<int> arr, int n, int k) {
    unordered_map < int, int > count_map;
    for ( int i = 0;
    i < n;
    i ++ ) count_map [ arr [ i ] ] ++;
    for ( int i = 0;
    i < n;
    i ++ ) if ( count_map [ arr [ i ] ] == k ) return arr [ i ];
    return - 1;
  }