title: Count Index Pairs Equal Elements Array
signature: class Solution {
  
      public Integer countIndexPairsEqualElementsArray(ArrayList<Integer> arr, Integer n) {
source_py: def count_index_pairs_equal_elements_array(arr, n):
      ans = 0
      for i in range(0, n):
          for j in range((i + 1), n):
              if (arr[i] == arr[j]):
                  ans += 1
      return ans
source_cpp: int count_index_pairs_equal_elements_array(vector<int> arr, int n) {
    int ans = 0;
    for ( int i = 0;
    i < n;
    i ++ ) for ( int j = i + 1;
    j < n;
    j ++ ) if ( arr [ i ] == arr [ j ] ) ans ++;
    return ans;
  }
question_info.extension: java
question_info.entry_fn_name: countIndexPairsEqualElementsArray
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"arr": [4, 6, 9, 16, 16, 21, 36, 41, 58, 60, 62, 73, 77, 81, 95], "n": 12}}, {"idx": 1, "outputs": 0, "inputs": {"arr": [-86, -72, -26, -34, 18, -62, -66], "n": 3}}, {"idx": 2, "outputs": 0, "inputs": {"arr": [1], "n": 0}}, {"idx": 3, "outputs": 0, "inputs": {"arr": [16], "n": 0}}, {"idx": 4, "outputs": 0, "inputs": {"arr": [-88, -80, -72, -68, -64, -26, 4, 14, 16, 22, 30, 32, 60, 74, 82], "n": 11}}, {"idx": 5, "outputs": 16, "inputs": {"arr": [0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1], "n": 9}}, {"idx": 6, "outputs": 0, "inputs": {"arr": [3, 9, 10, 12, 17, 23, 27, 29, 42, 44, 59, 61, 71, 76, 78, 82, 84, 84, 89, 90, 93, 93, 97, 97], "n": 15}}, {"idx": 7, "outputs": 0, "inputs": {"arr": [68, -40, -46, -20, -64, 90], "n": 5}}, {"idx": 8, "outputs": 61, "inputs": {"arr": [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": 15}}, {"idx": 9, "outputs": 3, "inputs": {"arr": [99, 17, 94, 43, 97, 17, 11, 58, 75, 94, 37, 22, 54, 31, 41, 4, 55, 69, 92, 80, 45, 97, 16, 33, 36, 17, 43, 82, 81, 64, 22, 65, 85, 44, 47, 14], "n": 23}}]
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 expected){
          try{
              Driver driver = new Driver();
              if (driver.run(arr, n,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(4, 6, 9, 16, 16, 21, 36, 41, 58, 60, 62, 73, 77, 81, 95)), 12, 1);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-86, -72, -26, -34, 18, -62, -66)), 3, 0);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1)), 0, 0);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(16)), 0, 0);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-88, -80, -72, -68, -64, -26, 4, 14, 16, 22, 30, 32, 60, 74, 82)), 11, 0);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1)), 9, 16);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(3, 9, 10, 12, 17, 23, 27, 29, 42, 44, 59, 61, 71, 76, 78, 82, 84, 84, 89, 90, 93, 93, 97, 97)), 15, 0);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(68, -40, -46, -20, -64, 90)), 5, 0);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 15, 61);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(99, 17, 94, 43, 97, 17, 11, 58, 75, 94, 37, 22, 54, 31, 41, 4, 55, 69, 92, 80, 45, 97, 16, 33, 36, 17, 43, 82, 81, 64, 22, 65, 85, 44, 47, 14)), 23, 3);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> arr, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(arr, n),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__