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