title: Find Repetitive Element 1 N 1 2
signature: class Solution {
  
      public Integer findRepetitiveElement1N12(ArrayList<Integer> arr, Integer n) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> arr, Integer n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(arr, 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, 4, 5, 5, 7, 7, 7, 8, 11, 14, 15, 18, 19, 20, 25, 25, 29, 29, 31, 32, 32, 33, 38, 42, 48, 52, 55, 60, 61, 63, 71, 74, 78, 82, 82, 84, 84, 87, 87, 88, 90, 93, 94, 94)), 31, 52);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(46, 2, 62, 60, 92, 4, 26, 66, 66, 90, 26, -14, 76, -20, -68)), 8, 46);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 1, 1, 1, 1, 1)), 4, 1);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(87, 67, 11, 47, 64, 81, 94, 75, 58, 77, 18, 2, 85, 26, 6, 44, 55, 19, 46, 49, 5, 69, 44, 12, 42, 66, 46, 9, 26, 49, 68, 95, 6, 9, 11, 72, 5, 67)), 34, 28);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-98, -94, -92, -82, -78, -64, -62, -58, -52, -44, -40, -38, -8, 6, 10, 20, 22, 28, 30, 30, 36, 54, 54, 58, 64, 68, 76, 78, 84, 88, 90, 94, 96)), 29, -32);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1)), 17, 16);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 14, 15, 15, 21, 34, 38, 39, 41, 50, 60, 74, 96, 97)), 7, 25);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(96, -12, -16, -52)), 3, 103);
          System.out.println(String.format("%s%s","TEST-7...",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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 21, 21);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(66, 21, 21, 59, 78, 8, 46, 41, 16, 32, 97, 93, 32, 86, 91, 61, 67, 61, 97, 49, 66, 35, 24, 35, 65, 45, 83)), 25, 9);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> arr, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(arr, n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def find_repetitive_element_1_n_1_2(arr, n):
      res = 0
      for i in range(0, (n - 1)):
          res = ((res ^ (i + 1)) ^ arr[i])
      res = (res ^ arr[(n - 1)])
      return res
source_cpp: int find_repetitive_element_1_n_1_2(vector<int> arr, int n) {
    int res = 0;
    for ( int i = 0;
    i < n - 1;
    i ++ ) res = res ^ ( i + 1 ) ^ arr [ i ];
    res = res ^ arr [ n - 1 ];
    return res;
  }