title: Find Largest D In Array Such That A B C D
signature: find_largest_d_in_array_such_that_a_b_c_d <- function(s, n) {
source_py: def find_largest_d_in_array_such_that_a_b_c_d(S, n):
      found = False
      S.sort()
      for i in range((n - 1), (- 1), (- 1)):
          for j in range(0, n):
              if (i == j):
                  continue
              for k in range((j + 1), n):
                  if (i == k):
                      continue
                  for l in range((k + 1), n):
                      if (i == l):
                          continue
                      if (S[i] == ((S[j] + S[k]) + S[l])):
                          found = True
                          return S[i]
      if (found == False):
          return (- 1)
source_cpp: int find_largest_d_in_array_such_that_a_b_c_d(vector<int> S, int n) {
    bool found = false;
    sort(S.begin(), S.end());
    for ( int i = n - 1;
    i >= 0;
    i -- ) {
      for ( int j = 0;
      j < n;
      j ++ ) {
        if ( i == j ) continue;
        for ( int k = j + 1;
        k < n;
        k ++ ) {
          if ( i == k ) continue;
          for ( int l = k + 1;
          l < n;
          l ++ ) {
            if ( i == l ) continue;
            if ( S [ i ] == S [ j ] + S [ k ] + S [ l ] ) {
              found = true;
              return S [ i ];
            }
          }
        }
      }
    }
    if ( found == false ) return INT_MIN;
  }