title: Find Repetitive Element 1 N 1
signature: function findRepetitiveElement1N1(arr: Array<number>, n: number): number {
source_py: def find_repetitive_element_1_n_1(arr, n):
      return (sum(arr) - (((n - 1) * n) // 2))
source_cpp: int find_repetitive_element_1_n_1(vector<int> arr, int n) {
    return accumulate(arr.begin(), arr.end(), 0 ) - ( ( n - 1 ) * n / 2 );
  }
question_info.test_list: [{"idx": 0, "outputs": 313, "inputs": {"arr": [4, 8, 27, 34, 39, 42, 43, 54, 72], "n": 5}}, {"idx": 1, "outputs": -520, "inputs": {"arr": [-38, -66, -38, -48, -96, 74, -32, -62, -34, -32, -88, -12, -8, -4], "n": 9}}, {"idx": 2, "outputs": -23, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], "n": 8}}, {"idx": 3, "outputs": 2101, "inputs": {"arr": [88, 86, 23, 81, 76, 16, 94, 64, 59, 50, 71, 62, 10, 89, 73, 64, 65, 96, 83, 40, 99, 40, 77, 33, 14, 62, 6, 89, 74, 96, 93, 29, 15, 93, 9, 58, 98, 76, 23, 23, 70, 99], "n": 31}}, {"idx": 4, "outputs": 76, "inputs": {"arr": [-96, -94, -82, -64, -56, -40, -36, -34, -32, -24, -24, -22, -20, -20, -20, -18, -18, -12, -10, -6, 16, 20, 20, 22, 26, 30, 36, 46, 46, 50, 50, 52, 64, 64, 64, 68, 72, 74, 76, 92, 96, 98], "n": 28}}, {"idx": 5, "outputs": -288, "inputs": {"arr": [0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1], "n": 25}}, {"idx": 6, "outputs": 1159, "inputs": {"arr": [2, 6, 7, 13, 19, 23, 37, 39, 42, 42, 43, 45, 52, 53, 55, 56, 59, 63, 66, 71, 76, 85, 86, 89, 92, 94, 96, 99], "n": 27}}, {"idx": 7, "outputs": -45, "inputs": {"arr": [52, -56, -12, 78, 6, 32, 0, 36, 34, -54, -74, -32], "n": 11}}, {"idx": 8, "outputs": -86, "inputs": {"arr": [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], "n": 15}}, {"idx": 9, "outputs": 951, "inputs": {"arr": [10, 42, 50, 5, 74, 81, 30, 76, 6, 34, 86, 4, 77, 71, 96, 22, 34, 50, 35, 16, 60, 11, 21, 38], "n": 13}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(arr: Array<number>, n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver([4, 8, 27, 34, 39, 42, 43, 54, 72], 5, 313);
    console.log(`TEST-0...${result}`);
  
    result = driver([-38, -66, -38, -48, -96, 74, -32, -62, -34, -32, -88, -12, -8, -4], 9, -520);
    console.log(`TEST-1...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], 8, -23);
    console.log(`TEST-2...${result}`);
  
    result = driver([88, 86, 23, 81, 76, 16, 94, 64, 59, 50, 71, 62, 10, 89, 73, 64, 65, 96, 83, 40, 99, 40, 77, 33, 14, 62, 6, 89, 74, 96, 93, 29, 15, 93, 9, 58, 98, 76, 23, 23, 70, 99], 31, 2101);
    console.log(`TEST-3...${result}`);
  
    result = driver([-96, -94, -82, -64, -56, -40, -36, -34, -32, -24, -24, -22, -20, -20, -20, -18, -18, -12, -10, -6, 16, 20, 20, 22, 26, 30, 36, 46, 46, 50, 50, 52, 64, 64, 64, 68, 72, 74, 76, 92, 96, 98], 28, 76);
    console.log(`TEST-4...${result}`);
  
    result = driver([0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1], 25, -288);
    console.log(`TEST-5...${result}`);
  
    result = driver([2, 6, 7, 13, 19, 23, 37, 39, 42, 42, 43, 45, 52, 53, 55, 56, 59, 63, 66, 71, 76, 85, 86, 89, 92, 94, 96, 99], 27, 1159);
    console.log(`TEST-6...${result}`);
  
    result = driver([52, -56, -12, 78, 6, 32, 0, 36, 34, -54, -74, -32], 11, -45);
    console.log(`TEST-7...${result}`);
  
    result = driver([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], 15, -86);
    console.log(`TEST-8...${result}`);
  
    result = driver([10, 42, 50, 5, 74, 81, 30, 76, 6, 34, 86, 4, 77, 71, 96, 22, 34, 50, 35, 16, 60, 11, 21, 38], 13, 951);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: findRepetitiveElement1N1
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js