title: Maximum Consecutive Numbers Present Array
signature: maximumConsecutiveNumbersPresentArray :: [Integer] -> Integer -> Integer
  maximumConsecutiveNumbersPresentArray arr n = 
test_code: import Text.Printf
  import Control.Exception (catch, SomeException)
  import Data.Typeable
  import qualified Data.List as List
  import qualified Data.Map as Map
  import qualified Data.Set as Set
  
  -- SOLUTION CODE
  -- ============================================
  
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  validateSolution :: Integer -> Integer -> Bool
  validateSolution actual expected = do
      actual == expected
  
  
  driver :: [Integer] -> Integer -> Integer -> String
  driver arr n expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME arr n) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver ([3, 5, 9, 24, 28, 31, 49, 54, 67, 85, 86, 94, 97, 97]) (11) (2) )
  
      printf "TEST-1...%s\n" (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) )
  
      printf "TEST-2...%s\n" (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) )
  
      printf "TEST-3...%s\n" (driver ([49, 61, 68, 4, 90, 89, 71, 74, 45, 61, 35, 41, 59]) (11) (2) )
  
      printf "TEST-4...%s\n" (driver ([-42, -8, 28, 56, 80, 96]) (4) (1) )
  
      printf "TEST-5...%s\n" (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) )
  
      printf "TEST-6...%s\n" (driver ([3, 4, 6, 6, 13, 27, 27, 29, 32, 36, 46, 50, 52, 65, 69, 70, 71, 83, 87, 91]) (10) (2) )
  
      printf "TEST-7...%s\n" (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) )
  
      printf "TEST-8...%s\n" (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) )
  
      printf "TEST-9...%s\n" (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) )
  
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;
  }