title: Find A Rotation With Maximum Hamming Distance
signature: pub fn find_a_rotation_with_maximum_hamming_distance(arr: Vec<i32>, n: i32) -> i32 {
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: i32, expected: i32)->bool{
  return actual==expected
  }
  pub fn driver(arr: Vec<i32>, n: i32, expected: i32)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        Vec::from([1, 4, 18, 22, 28, 34, 35, 39, 44, 45, 67, 73, 75, 79, 81, 83, 89, 93, 96]), 12, 
        12
      ));
      
      println!("TEST-1...{}", driver(
        Vec::from([52, -28]), 1, 
        0
      ));
      
      println!("TEST-2...{}", driver(
        Vec::from([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]), 21, 
        1
      ));
      
      println!("TEST-3...{}", driver(
        Vec::from([24]), 0, 
        0
      ));
      
      println!("TEST-4...{}", driver(
        Vec::from([-68, 14, 36, 62]), 2, 
        2
      ));
      
      println!("TEST-5...{}", driver(
        Vec::from([1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0]), 12, 
        6
      ));
      
      println!("TEST-6...{}", driver(
        Vec::from([7, 10, 19, 22, 24, 28, 29, 39, 46, 55, 62, 66, 68, 73, 74, 76, 83, 84, 85, 99]), 15, 
        15
      ));
      
      println!("TEST-7...{}", driver(
        Vec::from([-38, 56, 86, 12, 24, -90, -20, -46, 38, 92, -44, -74, 54, 50, 46, 50, -94, 64, 32, -84, 70]), 14, 
        14
      ));
      
      println!("TEST-8...{}", driver(
        Vec::from([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]), 8, 
        2
      ));
      
      println!("TEST-9...{}", driver(
        Vec::from([61, 89, 8]), 2, 
        2
      ));
      
  }
source_py: def find_a_rotation_with_maximum_hamming_distance(arr, n):
      brr = ([0] * ((2 * n) + 1))
      for i in range(n):
          brr[i] = arr[i]
      for i in range(n):
          brr[(n + i)] = arr[i]
      maxHam = 0
      for i in range(1, n):
          currHam = 0
          k = 0
          for j in range(i, (i + n)):
              if (brr[j] != arr[k]):
                  currHam += 1
                  k = (k + 1)
          if (currHam == n):
              return n
          maxHam = max(maxHam, currHam)
      return maxHam
source_cpp: int find_a_rotation_with_maximum_hamming_distance(vector<int> arr, int n) {
    int brr [ 2 * n + 1 ];
    for ( int i = 0;
    i < n;
    i ++ ) brr [ i ] = arr [ i ];
    for ( int i = 0;
    i < n;
    i ++ ) brr [ n + i ] = arr [ i ];
    int maxHam = 0;
    for ( int i = 1;
    i < n;
    i ++ ) {
      int currHam = 0;
      for ( int j = i, k = 0;
      j < ( i + n );
      j ++, k ++ ) if ( brr [ j ] != arr [ k ] ) currHam ++;
      if ( currHam == n ) return n;
      maxHam = max ( maxHam, currHam );
    }
    return maxHam;
  }