title: Find Largest D In Array Such That A B C D 1
signature: def find_largest_d_in_array_such_that_a_b_c_d_1(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;
    }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr, n, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, n),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([1, 1, 5, 7, 10, 35, 35, 45, 49, 50, 57, 58, 60, 64, 69, 83, 83, 87, 88, 89, 93, 94], 12, 58)
      print(f"TEST-0...{result}")
  
      result = driver([94, 90, 88, 0, -90, -68, 94, -2, -50, -92, 66, 32, 10, 8, -14, -96, 80, -60, 48, -96, 46, 24, 64, 2, -30, 28], 15, 94)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 17, 1)
      print(f"TEST-2...{result}")
  
      result = driver([83, 72, 91, 22, 96, 38, 71, 18, 58, 39, 7, 8, 65, 67], 7, -1000000000)
      print(f"TEST-3...{result}")
  
      result = driver([-96, -92, -88, -86, -82, -80, -78, -76, -74, -72, -62, -54, -42, -40, -38, -36, -36, -34, -32, -32, -26, -26, -22, -14, -14, 2, 16, 24, 26, 32, 32, 34, 48, 48, 64, 66, 70, 74, 82, 90], 28, 2)
      print(f"TEST-4...{result}")
  
      result = driver([1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1], 29, 1)
      print(f"TEST-5...{result}")
  
      result = driver([2, 2, 4, 10, 11, 13, 15, 20, 32, 33, 33, 42, 46, 46, 50, 54, 55, 55, 56, 57, 58, 63, 68, 79, 87, 94], 18, 55)
      print(f"TEST-6...{result}")
  
      result = driver([58, 78, 28, 54, -10, 46, -78, -68, -44, 64, 78, 80, -54, -38, -54, 60, 26, 96], 13, 80)
      print(f"TEST-7...{result}")
  
      result = driver([0, 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], 28, 1)
      print(f"TEST-8...{result}")
  
      result = driver([54, 55, 98, 18, 11, 55, 2, 95, 84, 14, 75, 12, 43, 54, 78, 34, 69, 24, 82, 65, 11, 49, 34, 60, 99, 71, 1, 17, 88, 12, 45, 46, 56, 28, 70, 34, 7, 55, 40, 12, 38, 56, 54, 53, 28], 24, 98)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: find_largest_d_in_array_such_that_a_b_c_d_1
question_info.test_list: [{"idx": 0, "outputs": 58, "inputs": {"arr": [1, 1, 5, 7, 10, 35, 35, 45, 49, 50, 57, 58, 60, 64, 69, 83, 83, 87, 88, 89, 93, 94], "n": 12}}, {"idx": 1, "outputs": 94, "inputs": {"arr": [94, 90, 88, 0, -90, -68, 94, -2, -50, -92, 66, 32, 10, 8, -14, -96, 80, -60, 48, -96, 46, 24, 64, 2, -30, 28], "n": 15}}, {"idx": 2, "outputs": 1, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 17}}, {"idx": 3, "outputs": -1000000000, "inputs": {"arr": [83, 72, 91, 22, 96, 38, 71, 18, 58, 39, 7, 8, 65, 67], "n": 7}}, {"idx": 4, "outputs": 2, "inputs": {"arr": [-96, -92, -88, -86, -82, -80, -78, -76, -74, -72, -62, -54, -42, -40, -38, -36, -36, -34, -32, -32, -26, -26, -22, -14, -14, 2, 16, 24, 26, 32, 32, 34, 48, 48, 64, 66, 70, 74, 82, 90], "n": 28}}, {"idx": 5, "outputs": 1, "inputs": {"arr": [1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1], "n": 29}}, {"idx": 6, "outputs": 55, "inputs": {"arr": [2, 2, 4, 10, 11, 13, 15, 20, 32, 33, 33, 42, 46, 46, 50, 54, 55, 55, 56, 57, 58, 63, 68, 79, 87, 94], "n": 18}}, {"idx": 7, "outputs": 80, "inputs": {"arr": [58, 78, 28, 54, -10, 46, -78, -68, -44, 64, 78, 80, -54, -38, -54, 60, 26, 96], "n": 13}}, {"idx": 8, "outputs": 1, "inputs": {"arr": [0, 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], "n": 28}}, {"idx": 9, "outputs": 98, "inputs": {"arr": [54, 55, 98, 18, 11, 55, 2, 95, 84, 14, 75, 12, 43, 54, 78, 34, 69, 24, 82, 65, 11, 49, 34, 60, 99, 71, 1, 17, 88, 12, 45, 46, 56, 28, 70, 34, 7, 55, 40, 12, 38, 56, 54, 53, 28], "n": 24}}]
question_info.entry_cls_name: Solution