title: Find Pair With Greatest Product In Array
signature: find_pair_with_greatest_product_in_array <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(4L, 78L, 84L), 2L, 
          -1L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-54L, 64L, 60L, 14L, 18L, -68L, -54L, -58L, 38L, -72L, -84L, 46L, 74L, 76L, 28L, -2L, 54L, 24L, 18L, -74L, -78L, 14L, -38L, -70L, 26L, -54L, -36L, -96L, -12L, 8L, 62L, -42L, -84L, 10L, -6L, 36L, -72L, 10L, 10L, -20L, 16L, 92L, -64L, -34L, 74L, -98L, 18L), 26L, 
          76L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 22L, 
          1L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(39L, 49L, 94L, 80L, 48L, 34L, 63L, 82L, 47L, 51L, 60L, 68L, 79L, 23L, 97L, 22L, 54L, 53L, 40L, 2L, 25L), 10L, 
          -1L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-90L, -52L, -10L, 12L, 72L), 3L, 
          -1L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 0L, 0L), 2L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(2L, 9L, 11L, 14L, 16L, 17L, 17L, 18L, 19L, 21L, 24L, 25L, 28L, 29L, 30L, 33L, 33L, 39L, 41L, 41L, 43L, 46L, 50L, 51L, 60L, 62L, 67L, 80L, 84L, 86L, 91L, 92L, 97L), 27L, 
          60L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(4L), 0L, 
          -1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 16L, 
          1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(52L, 8L, 31L, 92L, 20L, 18L, 34L, 5L, 15L, 8L, 73L, 20L, 40L, 61L, 80L, 51L, 95L, 73L, 38L, 30L, 21L, 69L, 52L, 38L, 68L, 77L), 22L, 
          40L
      )))
  
  }
  
  main()
source_py: def find_pair_with_greatest_product_in_array(arr, n):
      result = (- 1)
      for i in range(n):
          for j in range((n - 1)):
              for k in range((j + 1), n):
                  if ((arr[j] * arr[k]) == arr[i]):
                      result = max(result, arr[i])
      return result
source_cpp: int find_pair_with_greatest_product_in_array(vector<int> arr, int n) {
    int result = - 1;
    for ( int i = 0;
    i < n;
    i ++ ) for ( int j = 0;
    j < n - 1;
    j ++ ) for ( int k = j + 1;
    k < n;
    k ++ ) if ( arr [ j ] * arr [ k ] == arr [ i ] ) result = max ( result, arr [ i ] );
    return result;
  }