title: Array Range Queries Elements Frequency Value
signature: class Solution {
  
      public Integer arrayRangeQueriesElementsFrequencyValue(Integer start, Integer end_arg1, ArrayList<Integer> arr) {
source_py: def array_range_queries_elements_frequency_value(start, end, arr):
      frequency = dict()
      for i in range(start, (end + 1)):
          if (arr[i] in frequency.keys()):
              frequency[arr[i]] += 1
          else:
              frequency[arr[i]] = 1
      count = 0
      for x in frequency:
          if (x == frequency[x]):
              count += 1
      return count
source_cpp: int array_range_queries_elements_frequency_value(int start, int end, vector<int> arr) {
    unordered_map < int, int > frequency;
    for ( int i = start;
    i <= end;
    i ++ ) frequency [ arr [ i ] ] ++;
    int count = 0;
    for ( auto x : frequency ) if ( x . first == x . second ) count ++;
    return count;
  }
question_info.extension: java
question_info.entry_fn_name: arrayRangeQueriesElementsFrequencyValue
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 3, "inputs": {"start": 0, "end_arg1": 31, "arr": [1, 2, 2, 3, 3, 3, 12, 13, 18, 18, 26, 28, 29, 36, 37, 39, 40, 49, 55, 57, 63, 69, 69, 73, 85, 86, 87, 87, 89, 89, 90, 91, 92, 93, 93, 93, 95, 99]}}, {"idx": 1, "outputs": 2, "inputs": {"start": 1, "end_arg1": 25, "arr": [24, -62, 2, 1, 94, 56, -22, -70, -22, -34, -92, -18, 56, 2, 60, 38, -88, 16, -28, 30, -30, 58, -80, 94, 6, 56]}}, {"idx": 2, "outputs": 1, "inputs": {"start": 3, "end_arg1": 4, "arr": [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}}, {"idx": 3, "outputs": 0, "inputs": {"start": 10, "end_arg1": 15, "arr": [84, 13, 81, 40, 87, 82, 50, 30, 90, 80, 81, 70, 14, 54, 72, 93, 78, 27, 61]}}, {"idx": 4, "outputs": 0, "inputs": {"start": 2, "end_arg1": 3, "arr": [-20, 20, 34, 60, 90]}}, {"idx": 5, "outputs": 1, "inputs": {"start": 0, "end_arg1": 6, "arr": [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}, {"idx": 6, "outputs": 0, "inputs": {"start": 14, "end_arg1": 18, "arr": [11, 18, 18, 19, 25, 30, 42, 42, 56, 58, 63, 66, 67, 68, 69, 75, 78, 83, 83]}}, {"idx": 7, "outputs": 0, "inputs": {"start": 29, "end_arg1": 33, "arr": [-24, -82, 24, -84, 94, 2, -30, 86, 58, -56, -96, 60, -38, 76, 94, 74, -98, -84, -38, 46, 4, -84, -90, -28, -50, 46, 16, 28, -14, -82, -64, 42, 64, -2, -40, 96, 60, 2, -86, 32, 38, -66]}}, {"idx": 8, "outputs": 0, "inputs": {"start": 31, "end_arg1": 19, "arr": [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]}}, {"idx": 9, "outputs": 0, "inputs": {"start": 21, "end_arg1": 32, "arr": [2, 91, 42, 85, 97, 92, 24, 39, 63, 89, 31, 59, 51, 89, 72, 62, 26, 92, 75, 4, 6, 13, 20, 95, 22, 30, 52, 60, 37, 27, 49, 15, 67, 26]}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer start, Integer end_arg1, ArrayList<Integer> arr, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(start, end_arg1, arr,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(0, 31, new ArrayList<>(Arrays.asList(1, 2, 2, 3, 3, 3, 12, 13, 18, 18, 26, 28, 29, 36, 37, 39, 40, 49, 55, 57, 63, 69, 69, 73, 85, 86, 87, 87, 89, 89, 90, 91, 92, 93, 93, 93, 95, 99)), 3);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(1, 25, new ArrayList<>(Arrays.asList(24, -62, 2, 1, 94, 56, -22, -70, -22, -34, -92, -18, 56, 2, 60, 38, -88, 16, -28, 30, -30, 58, -80, 94, 6, 56)), 2);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(3, 4, new ArrayList<>(Arrays.asList(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 1);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(10, 15, new ArrayList<>(Arrays.asList(84, 13, 81, 40, 87, 82, 50, 30, 90, 80, 81, 70, 14, 54, 72, 93, 78, 27, 61)), 0);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(2, 3, new ArrayList<>(Arrays.asList(-20, 20, 34, 60, 90)), 0);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(0, 6, new ArrayList<>(Arrays.asList(1, 0, 0, 0, 0, 0, 0, 0, 0, 0)), 1);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(14, 18, new ArrayList<>(Arrays.asList(11, 18, 18, 19, 25, 30, 42, 42, 56, 58, 63, 66, 67, 68, 69, 75, 78, 83, 83)), 0);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(29, 33, new ArrayList<>(Arrays.asList(-24, -82, 24, -84, 94, 2, -30, 86, 58, -56, -96, 60, -38, 76, 94, 74, -98, -84, -38, 46, 4, -84, -90, -28, -50, 46, 16, 28, -14, -82, -64, 42, 64, -2, -40, 96, 60, 2, -86, 32, 38, -66)), 0);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(31, 19, new ArrayList<>(Arrays.asList(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)), 0);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(21, 32, new ArrayList<>(Arrays.asList(2, 91, 42, 85, 97, 92, 24, 39, 63, 89, 31, 59, 51, 89, 72, 62, 26, 92, 75, 4, 6, 13, 20, 95, 22, 30, 52, 60, 37, 27, 49, 15, 67, 26)), 0);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer start, Integer end_arg1, ArrayList<Integer> arr, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(start, end_arg1, arr),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer 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__