title: Maximum Consecutive Numbers Present Array
signature: function maximum_consecutive_numbers_present_array(arr, n)
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;
  }
question_info.entry_fn_name: maximum_consecutive_numbers_present_array
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(arr, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({3, 5, 9, 24, 28, 31, 49, 54, 67, 85, 86, 94, 97, 97}, 11, 2)
      print(string.format("TEST-0...%s",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)
      print(string.format("TEST-1...%s",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)
      print(string.format("TEST-2...%s",result))
  
      result = driver({49, 61, 68, 4, 90, 89, 71, 74, 45, 61, 35, 41, 59}, 11, 2)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-42, -8, 28, 56, 80, 96}, 4, 1)
      print(string.format("TEST-4...%s",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)
      print(string.format("TEST-5...%s",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)
      print(string.format("TEST-6...%s",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)
      print(string.format("TEST-7...%s",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)
      print(string.format("TEST-8...%s",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)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 2, "inputs": {"arr": [3, 5, 9, 24, 28, 31, 49, 54, 67, 85, 86, 94, 97, 97], "n": 11}}, {"idx": 1, "outputs": 1, "inputs": {"arr": [-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], "n": 29}}, {"idx": 2, "outputs": 2, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 13}}, {"idx": 3, "outputs": 2, "inputs": {"arr": [49, 61, 68, 4, 90, 89, 71, 74, 45, 61, 35, 41, 59], "n": 11}}, {"idx": 4, "outputs": 1, "inputs": {"arr": [-42, -8, 28, 56, 80, 96], "n": 4}}, {"idx": 5, "outputs": 2, "inputs": {"arr": [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], "n": 17}}, {"idx": 6, "outputs": 2, "inputs": {"arr": [3, 4, 6, 6, 13, 27, 27, 29, 32, 36, 46, 50, 52, 65, 69, 70, 71, 83, 87, 91], "n": 10}}, {"idx": 7, "outputs": 1, "inputs": {"arr": [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], "n": 15}}, {"idx": 8, "outputs": 1, "inputs": {"arr": [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], "n": 15}}, {"idx": 9, "outputs": 3, "inputs": {"arr": [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], "n": 25}}]