title: Smallest Difference Pair Values Two Unsorted Arrays
signature: smallest_difference_pair_values_two_unsorted_arrays <- function(a, b, m, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(a, b, m, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(a, b, m, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(2L, 2L, 11L, 13L, 18L, 18L, 23L, 25L, 28L, 28L, 37L, 39L, 53L, 56L, 67L, 70L, 74L, 74L, 75L, 79L, 80L, 82L, 84L, 89L, 94L, 95L, 95L, 98L, 98L), list(5L, 6L, 11L, 13L, 13L, 16L, 17L, 19L, 23L, 25L, 28L, 31L, 31L, 39L, 41L, 44L, 45L, 52L, 62L, 64L, 70L, 71L, 73L, 78L, 78L, 79L, 85L, 86L, 92L), 28L, 14L, 
          0L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-94L, -78L, -78L, -72L, -72L, -72L, -70L, -70L, -64L, -62L, -50L, -48L, -48L, -44L, -44L, -40L, -36L, -36L, -30L, -24L, -24L, -22L, -12L, -10L, -8L, -4L, -4L, 0L, 6L, 10L, 22L, 30L, 38L, 56L, 62L, 72L, 86L), list(-98L, -98L, -90L, -84L, -80L, -78L, -68L, -62L, -52L, -50L, -42L, -30L, -26L, -24L, -24L, -24L, -12L, 2L, 10L, 14L, 18L, 22L, 26L, 26L, 36L, 42L, 50L, 60L, 62L, 64L, 64L, 72L, 76L, 78L, 84L, 86L, 92L), 23L, 33L, 
          0L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(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, 1L), 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), 14L, 16L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(2L, 9L, 15L, 24L, 28L, 28L, 39L, 47L, 57L, 61L, 71L, 82L, 90L), list(11L, 26L, 27L, 41L, 47L, 49L, 51L, 54L, 70L, 77L, 84L, 85L, 92L), 7L, 8L, 
          1L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-92L, -90L, -90L, -28L, -16L, -14L, -14L, -8L, 42L, 52L, 62L, 84L), list(-98L, -98L, -58L, -6L, 14L, 16L, 18L, 46L, 52L, 52L, 52L, 56L), 11L, 6L, 
          2L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 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, 1L, 1L, 1L, 1L, 1L, 1L), 35L, 33L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(6L, 7L, 7L, 12L, 15L, 15L, 21L, 24L, 26L, 26L, 28L, 36L, 38L, 42L, 46L, 52L, 55L, 56L, 59L, 62L, 63L, 65L, 65L, 66L, 68L, 71L, 73L, 77L, 77L, 77L, 77L, 85L, 87L, 87L, 88L, 90L, 93L, 94L, 98L), list(1L, 3L, 4L, 4L, 6L, 7L, 8L, 8L, 15L, 17L, 18L, 18L, 20L, 23L, 23L, 24L, 25L, 25L, 26L, 33L, 39L, 43L, 46L, 54L, 59L, 67L, 69L, 69L, 69L, 69L, 76L, 76L, 81L, 81L, 85L, 86L, 86L, 91L, 95L), 30L, 20L, 
          0L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-82L, -68L, -68L, -60L, -60L, -38L, -20L, -16L, 4L, 18L, 18L, 22L, 24L, 30L, 34L, 44L, 70L, 78L, 88L, 90L, 94L), list(-74L, -68L, -64L, -62L, -60L, -52L, -50L, -44L, -36L, -34L, -32L, -30L, -20L, -18L, -14L, -2L, 18L, 62L, 62L, 84L, 98L), 16L, 12L, 
          0L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 1L), list(0L, 0L, 1L), 2L, 1L, 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(2L, 7L, 7L, 9L, 14L, 15L, 16L, 20L, 21L, 26L, 35L, 37L, 40L, 45L, 46L, 47L, 53L, 56L, 58L, 61L, 62L, 67L, 70L, 70L, 71L, 73L, 81L, 85L, 85L, 90L, 94L, 98L, 99L), list(1L, 7L, 14L, 16L, 18L, 19L, 24L, 27L, 28L, 29L, 29L, 37L, 41L, 44L, 45L, 48L, 49L, 55L, 64L, 67L, 67L, 71L, 72L, 79L, 80L, 84L, 86L, 88L, 88L, 92L, 94L, 98L, 99L), 20L, 25L, 
          0L
      )))
  
  }
  
  main()
source_py: def smallest_difference_pair_values_two_unsorted_arrays(A, B, m, n):
      A.sort()
      B.sort()
      a = 0
      b = 0
      result = sys.maxsize
      while ((a < m) and (b < n)):
          if (abs((A[a] - B[b])) < result):
              result = abs((A[a] - B[b]))
          if (A[a] < B[b]):
              a += 1
          else:
              b += 1
      return result
source_cpp: int smallest_difference_pair_values_two_unsorted_arrays(vector<int> A, vector<int> B, int m, int n) {
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int a = 0, b = 0;
    int result = INT_MAX;
    while ( a < m && b < n ) {
      if ( abs ( A [ a ] - B [ b ] ) < result ) result = abs ( A [ a ] - B [ b ] );
      if ( A [ a ] < B [ b ] ) a ++;
      else b ++;
    }
    return result;
  }