title: Find Largest D In Array Such That A B C D 1
signature: function findLargestDInArraySuchThatABCD1(arr, n) {
source_py: def find_largest_d_in_array_such_that_a_b_c_d_1(arr, n):
      mp = dict()
      for i in range((n - 1)):
          for j in range((i + 1), n):
              mp[(arr[i] + arr[j])] = (i, j)
      d = (- (10 ** 9))
      for i in range((n - 1)):
          for j in range((i + 1), n):
              abs_diff = abs((arr[i] - arr[j]))
              if (abs_diff in mp.keys()):
                  p = mp[abs_diff]
                  if ((p[0] != i) and (p[0] != j) and (p[1] != i) and (p[1] != j)):
                      d = max(d, max(arr[i], arr[j]))
      return d
source_cpp: int find_largest_d_in_array_such_that_a_b_c_d_1(vector<int> arr, int n) {
    unordered_map < int, pair < int, int > > mp;
    for ( int i = 0;
    i < n - 1;
    i ++ ) for ( int j = i + 1;
    j < n;
    j ++ ) mp [ arr [ i ] + arr [ j ] ] = {
      i, j };
      int d = INT_MIN;
      for ( int i = 0;
      i < n - 1;
      i ++ ) {
        for ( int j = i + 1;
        j < n;
        j ++ ) {
          int abs_diff = abs ( arr [ i ] - arr [ j ] );
          if ( mp . find ( abs_diff ) != mp . end ( ) ) {
            pair < int, int > p = mp [ abs_diff ];
            if ( p . first != i && p . first != j && p . second != i && p . second != j ) d = max ( d, max ( arr [ i ], arr [ j ] ) );
          }
        }
      }
      return d;
    }