title: Maximum Consecutive Numbers Present Array
signature: function maximumConsecutiveNumbersPresentArray(arr: Array<number>, n: number): number {
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([3, 5, 9, 24, 28, 31, 49, 54, 67, 85, 86, 94, 97, 97], 11, 2);
    console.log(`TEST-0...${result}`);
  
    result = driver([-34, 16, -80, -10, 80, 2, 50, -74, -76, 36, -84, -24, 74, -54, -22, 46, 80, 58, -8, 70, 24, -88, 52, 62, 30, 42, 48, 16, 78, -82, 64, -36, 84, -72], 29, 1);
    console.log(`TEST-1...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 13, 2);
    console.log(`TEST-2...${result}`);
  
    result = driver([49, 61, 68, 4, 90, 89, 71, 74, 45, 61, 35, 41, 59], 11, 2);
    console.log(`TEST-3...${result}`);
  
    result = driver([-42, -8, 28, 56, 80, 96], 4, 1);
    console.log(`TEST-4...${result}`);
  
    result = driver([1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1], 17, 2);
    console.log(`TEST-5...${result}`);
  
    result = driver([3, 4, 6, 6, 13, 27, 27, 29, 32, 36, 46, 50, 52, 65, 69, 70, 71, 83, 87, 91], 10, 2);
    console.log(`TEST-6...${result}`);
  
    result = driver([64, -76, 28, 6, 56, 18, 32, -50, -20, 18, -26, -90, 32, 50, -18, 98, 84, 40, 50, 88, -70, -6, -24, -44, -96, -58, 48, -78, -14], 15, 1);
    console.log(`TEST-7...${result}`);
  
    result = driver([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], 15, 1);
    console.log(`TEST-8...${result}`);
  
    result = driver([50, 48, 61, 87, 7, 78, 93, 44, 16, 88, 98, 15, 73, 93, 43, 46, 42, 34, 1, 35, 79, 35, 84, 60, 18, 79, 17, 4, 78, 1, 20, 64], 25, 3);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
source_py: def maximum_consecutive_numbers_present_array(arr, n):
      S = set()
      for i in range(n):
          S.add(arr[i])
      ans = 0
      for i in range(n):
          if S.__contains__(arr[i]):
              j = arr[i]
              while S.__contains__(j):
                  j += 1
              ans = max(ans, (j - arr[i]))
      return ans
source_cpp: int maximum_consecutive_numbers_present_array(vector<int> arr, int n) {
    unordered_set < int > S;
    for ( int i = 0;
    i < n;
    i ++ ) S . insert ( arr [ i ] );
    int ans = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( S . find ( arr [ i ] - 1 ) == S . end ( ) ) {
        int j = arr [ i ];
        while ( S . find ( j ) != S . end ( ) ) j ++;
        ans = max ( ans, j - arr [ i ] );
      }
    }
    return ans;
  }