title: Find Largest D In Array Such That A B C D
signature: class Solution {
  
      public Integer findLargestDInArraySuchThatABCD(ArrayList<Integer> s, Integer 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;
  }
question_info.extension: java
question_info.entry_fn_name: findLargestDInArraySuchThatABCD
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 75, "inputs": {"s": [8, 12, 14, 15, 16, 20, 27, 28, 29, 30, 35, 41, 46, 51, 53, 55, 55, 58, 63, 64, 72, 73, 75, 75, 75, 82, 82, 86, 89, 91, 92, 94, 95, 95, 97, 97, 98], "n": 24}}, {"idx": 1, "outputs": 48, "inputs": {"s": [-96, -82, -62, -58, -56, -50, -44, -44, -40, -28, -22, -20, -12, -2, 10, 26, 34, 42, 48, 74, 86, 92], "n": 19}}, {"idx": 2, "outputs": 0, "inputs": {"s": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1], "n": 8}}, {"idx": 3, "outputs": -1, "inputs": {"s": [10, 10, 47, 54, 55, 58, 65, 66, 67, 77, 84], "n": 5}}, {"idx": 4, "outputs": -1, "inputs": {"s": [-46, -28, -20, -18, 4, 8, 18, 38, 90, 90], "n": 6}}, {"idx": 5, "outputs": 1, "inputs": {"s": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1], "n": 35}}, {"idx": 6, "outputs": 91, "inputs": {"s": [11, 13, 14, 21, 26, 28, 36, 39, 41, 42, 43, 44, 49, 49, 57, 58, 59, 59, 63, 64, 67, 69, 70, 75, 78, 79, 83, 83, 86, 91, 92, 93, 96, 96, 96, 97], "n": 30}}, {"idx": 7, "outputs": -30, "inputs": {"s": [-88, -82, -82, -76, -70, -66, -62, -56, -48, -48, -32, -30, -18, -16, 0, 4, 34, 38, 46, 46, 50, 52, 54, 54, 62, 74, 76, 78, 96], "n": 16}}, {"idx": 8, "outputs": 1, "inputs": {"s": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 17}}, {"idx": 9, "outputs": 92, "inputs": {"s": [4, 5, 6, 9, 11, 14, 18, 20, 21, 25, 33, 49, 55, 56, 58, 61, 66, 66, 68, 74, 74, 87, 92, 99], "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> s, Integer n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(s, 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(8, 12, 14, 15, 16, 20, 27, 28, 29, 30, 35, 41, 46, 51, 53, 55, 55, 58, 63, 64, 72, 73, 75, 75, 75, 82, 82, 86, 89, 91, 92, 94, 95, 95, 97, 97, 98)), 24, 75);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-96, -82, -62, -58, -56, -50, -44, -44, -40, -28, -22, -20, -12, -2, 10, 26, 34, 42, 48, 74, 86, 92)), 19, 48);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 1, 1, 1)), 8, 0);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(10, 10, 47, 54, 55, 58, 65, 66, 67, 77, 84)), 5, -1);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-46, -28, -20, -18, 4, 8, 18, 38, 90, 90)), 6, -1);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1)), 35, 1);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(11, 13, 14, 21, 26, 28, 36, 39, 41, 42, 43, 44, 49, 49, 57, 58, 59, 59, 63, 64, 67, 69, 70, 75, 78, 79, 83, 83, 86, 91, 92, 93, 96, 96, 96, 97)), 30, 91);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-88, -82, -82, -76, -70, -66, -62, -56, -48, -48, -32, -30, -18, -16, 0, 4, 34, 38, 46, 46, 50, 52, 54, 54, 62, 74, 76, 78, 96)), 16, -30);
          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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 17, 1);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(4, 5, 6, 9, 11, 14, 18, 20, 21, 25, 33, 49, 55, 56, 58, 61, 66, 66, 68, 74, 74, 87, 92, 99)), 23, 92);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> s, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(s, 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__