title: Count Index Pairs Equal Elements Array 1
signature: function countIndexPairsEqualElementsArray1(arr, n) {
source_py: def count_index_pairs_equal_elements_array_1(arr, n):
      mp = dict()
      for i in range(n):
          if (arr[i] in mp.keys()):
              mp[arr[i]] += 1
          else:
              mp[arr[i]] = 1
      ans = 0
      for it in mp:
          count = mp[it]
          ans += ((count * (count - 1)) // 2)
      return ans
source_cpp: int count_index_pairs_equal_elements_array_1(vector<int> arr, int n) {
    unordered_map < int, int > mp;
    for ( int i = 0;
    i < n;
    i ++ ) mp [ arr [ i ] ] ++;
    int ans = 0;
    for ( auto it = mp . begin ( );
    it != mp . end ( );
    it ++ ) {
      int count = it -> second;
      ans += ( count * ( count - 1 ) ) / 2;
    }
    return ans;
  }