title: Find A Triplet That Sum To A Given Value 1
signature: class Solution {
  
      public Boolean findATripletThatSumToAGivenValue1(ArrayList<Integer> a, Integer arr_size, Integer sum) {
source_py: def find_a_triplet_that_sum_to_a_given_value_1(A, arr_size, sum):
      A.sort()
      for i in range(0, (arr_size - 2)):
          l = (i + 1)
          r = (arr_size - 1)
          while (l < r):
              if (((A[i] + A[l]) + A[r]) == sum):
                  print('Triplet is', A[i], ', ', A[l], ', ', A[r])
                  return True
              elif (((A[i] + A[l]) + A[r]) < sum):
                  l += 1
              else:
                  r -= 1
      return False
source_cpp: bool find_a_triplet_that_sum_to_a_given_value_1(vector<int> A, int arr_size, int sum) {
    int l, r;
    sort(A.begin(), A.end());
    for ( int i = 0;
    i < arr_size - 2;
    i ++ ) {
      l = i + 1;
      r = arr_size - 1;
      while ( l < r ) {
        if ( A [ i ] + A [ l ] + A [ r ] == sum ) {
          return true;
        }
        else if ( A [ i ] + A [ l ] + A [ r ] < sum ) l ++;
        else r --;
      }
    }
    return false;
  }
question_info.extension: java
question_info.entry_fn_name: findATripletThatSumToAGivenValue1
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": false, "inputs": {"a": [28, 47, 65, 89], "arr_size": 3, "sum": 3}}, {"idx": 1, "outputs": true, "inputs": {"a": [-90, -88, -88, -70, -66, -64, -64, -56, -52, -48, -42, -40, -26, -16, -14, -8, -2, 0, 6, 12, 12, 14, 18, 46, 50, 52, 52, 52, 58, 68, 70, 70, 74, 78, 84, 96, 98], "arr_size": 22, "sum": 24}}, {"idx": 2, "outputs": false, "inputs": {"a": [0], "arr_size": 0, "sum": 0}}, {"idx": 3, "outputs": false, "inputs": {"a": [22, 49, 52, 54, 66, 80, 87, 93], "arr_size": 5, "sum": 7}}, {"idx": 4, "outputs": false, "inputs": {"a": [-96, -92, -86, -74, -62, -60, -56, -54, -46, -38, -32, -26, -16, -16, -8, -4, 0, 6, 20, 28, 42, 44, 56], "arr_size": 13, "sum": 19}}, {"idx": 5, "outputs": false, "inputs": {"a": [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], "arr_size": 39, "sum": 39}}, {"idx": 6, "outputs": false, "inputs": {"a": [1, 2, 16, 16, 20, 24, 24, 38, 41, 54, 57, 72, 79, 83, 89, 90, 96, 97, 98], "arr_size": 12, "sum": 12}}, {"idx": 7, "outputs": false, "inputs": {"a": [-30, 22, 52, 78], "arr_size": 2, "sum": 3}}, {"idx": 8, "outputs": false, "inputs": {"a": [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], "arr_size": 21, "sum": 16}}, {"idx": 9, "outputs": true, "inputs": {"a": [1, 4, 6, 9, 10, 11, 11, 16, 16, 20, 23, 26, 28, 28, 40, 41, 41, 44, 48, 49, 50, 51, 52, 58, 58, 72, 77, 83, 83, 92, 92, 98], "arr_size": 29, "sum": 27}}]
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> a, Integer arr_size, Integer sum, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(a, arr_size, sum,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(28, 47, 65, 89)), 3, 3, false);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-90, -88, -88, -70, -66, -64, -64, -56, -52, -48, -42, -40, -26, -16, -14, -8, -2, 0, 6, 12, 12, 14, 18, 46, 50, 52, 52, 52, 58, 68, 70, 70, 74, 78, 84, 96, 98)), 22, 24, true);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0)), 0, 0, false);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(22, 49, 52, 54, 66, 80, 87, 93)), 5, 7, false);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-96, -92, -86, -74, -62, -60, -56, -54, -46, -38, -32, -26, -16, -16, -8, -4, 0, 6, 20, 28, 42, 44, 56)), 13, 19, false);
          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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 39, 39, false);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 2, 16, 16, 20, 24, 24, 38, 41, 54, 57, 72, 79, 83, 89, 90, 96, 97, 98)), 12, 12, false);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-30, 22, 52, 78)), 2, 3, false);
          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, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 21, 16, false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 4, 6, 9, 10, 11, 11, 16, 16, 20, 23, 26, 28, 28, 40, 41, 41, 44, 48, 49, 50, 51, 52, 58, 58, 72, 77, 83, 83, 92, 92, 98)), 29, 27, true);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> a, Integer arr_size, Integer sum, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(a, arr_size, sum),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean 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__