title: Minimum Xor Value Pair 1
signature: int minimumXorValuePair1(vector<int> arr, int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(vector<int> arr, int n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver({8, 11, 12, 27, 32, 32, 36, 56, 57, 66, 68, 70, 74, 78, 82, 83, 96}, 10, 0); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver({-60, -8, 4, 38, 40, 42, 48, 66}, 7, -4); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver({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}, 19, 0); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver({2, 3, 4, 6, 7, 7, 10, 11, 12, 15, 16, 20, 24, 28, 29, 32, 36, 37, 38, 44, 48, 49, 50, 52, 57, 57, 57, 61, 63, 64, 65, 66, 67, 68, 70, 76, 78, 81, 82, 86, 87, 89, 91, 95, 95, 98}, 36, 0); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver({-88, -84, -76, -58, -40, -38, -28, -24, -20, -14, -12, 16, 20, 28, 28, 30, 40, 44, 56, 58, 60, 92, 92}, 13, -28); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 20, 0); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver({6, 6, 19, 31, 41, 45, 49, 56, 78, 96, 98}, 6, 0); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver({-90, -84, -4, 22, 62}, 3, 10); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver({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}, 21, 0); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver({7, 10, 13, 20, 28, 29, 34, 37, 39, 42, 43, 56, 58, 65, 69, 72, 74, 83, 91, 92, 93, 99}, 14, 1); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def minimum_xor_value_pair_1(arr, n):
      arr.sort()
      minXor = int(sys.float_info.max)
      val = 0
      for i in range(0, (n - 1)):
          val = (arr[i] ^ arr[(i + 1)])
          minXor = min(minXor, val)
      return minXor
source_cpp: int minimum_xor_value_pair_1(vector<int> arr, int n) {
    sort(arr.begin(), arr.end());
    int minXor = INT_MAX;
    int val = 0;
    for ( int i = 0;
    i < n - 1;
    i ++ ) {
      val = arr [ i ] ^ arr [ i + 1 ];
      minXor = min ( minXor, val );
    }
    return minXor;
  }