title: Count Number Of Occurrences Or Frequency In A Sorted Array
signature: count_number_of_occurrences_or_frequency_in_a_sorted_array <- function(arr, n, x) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, x, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n, x), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(16L, 18L, 24L, 27L, 34L, 36L, 41L, 43L, 43L, 52L, 59L, 76L, 86L, 87L, 90L, 91L, 94L, 96L, 98L, 98L), 14L, 43L, 
          2L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(64L, 66L, -36L), 1L, 64L, 
          1L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L), 2L, 0L, 
          2L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(9L, 85L, 34L, 43L, 70L, 96L, 44L, 7L, 27L, 33L, 34L, 5L, 91L, 84L, 76L, 45L, 20L, 37L, 15L, 37L, 20L, 24L, 13L, 49L, 74L, 13L, 50L, 81L, 81L, 66L, 23L, 36L, 91L, 80L, 61L, 15L, 96L, 70L, 90L, 25L, 16L, 62L, 75L, 63L, 6L, 65L, 38L, 12L), 43L, 5L, 
          1L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-98L, -98L, -98L, -34L, -32L, -26L, -12L, 0L, 18L, 52L, 68L, 72L), 11L, -98L, 
          3L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L), 11L, 1L, 
          5L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(1L, 3L, 6L, 6L, 10L, 12L, 15L, 16L, 21L, 22L, 23L, 29L, 33L, 37L, 40L, 40L, 43L, 52L, 55L, 59L, 64L, 65L, 71L, 72L, 80L, 83L, 86L, 86L, 88L, 88L), 29L, 40L, 
          2L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-14L, -30L, -38L, -38L, -8L, 40L, -34L, 2L, -84L, 68L, -42L, 38L, -14L, 0L, -64L, 12L, -2L, -38L, -8L, -44L, -88L, -34L, -80L, -36L, 82L, 70L, 96L, -32L, 16L, -52L, -12L, -46L, -28L, -86L, 30L, -14L, 50L, -44L, 22L, 30L, -4L, 78L, 52L), 39L, 26L, 
          0L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(1L, 1L, 1L, 1L), 2L, 3L, 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(11L, 50L, 1L, 93L, 12L, 7L, 55L, 35L, 36L, 62L, 61L, 71L, 16L), 11L, 8L, 
          0L
      )))
  
  }
  
  main()
source_py: def count_number_of_occurrences_or_frequency_in_a_sorted_array(arr, n, x):
      res = 0
      for i in range(n):
          if (x == arr[i]):
              res += 1
      return res
source_cpp: int count_number_of_occurrences_or_frequency_in_a_sorted_array(vector<int> arr, int n, int x) {
    int res = 0;
    for ( int i = 0;
    i < n;
    i ++ ) if ( x == arr [ i ] ) res ++;
    return res;
  }