title: Find A Triplet That Sum To A Given Value 1
signature: pub fn find_a_triplet_that_sum_to_a_given_value_1(a: Vec<i32>, arr_size: i32, sum: i32) -> bool {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: bool, expected: bool)->bool{
  return actual==expected
  }
  pub fn driver(a: Vec<i32>, arr_size: i32, sum: i32, expected: bool)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(a, arr_size, sum), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        Vec::from([28, 47, 65, 89]), 3, 3, 
        false
      ));
      
      println!("TEST-1...{}", driver(
        Vec::from([-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
      ));
      
      println!("TEST-2...{}", driver(
        Vec::from([0]), 0, 0, 
        false
      ));
      
      println!("TEST-3...{}", driver(
        Vec::from([22, 49, 52, 54, 66, 80, 87, 93]), 5, 7, 
        false
      ));
      
      println!("TEST-4...{}", driver(
        Vec::from([-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
      ));
      
      println!("TEST-5...{}", driver(
        Vec::from([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
      ));
      
      println!("TEST-6...{}", driver(
        Vec::from([1, 2, 16, 16, 20, 24, 24, 38, 41, 54, 57, 72, 79, 83, 89, 90, 96, 97, 98]), 12, 12, 
        false
      ));
      
      println!("TEST-7...{}", driver(
        Vec::from([-30, 22, 52, 78]), 2, 3, 
        false
      ));
      
      println!("TEST-8...{}", driver(
        Vec::from([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
      ));
      
      println!("TEST-9...{}", driver(
        Vec::from([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
      ));
      
  }
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;
  }