title: Remove Minimum Elements Either Side 2Min Max
signature: removeMinimumElementsEitherSide2MinMax :: [Integer] -> Integer -> Integer
  removeMinimumElementsEitherSide2MinMax 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 ([32, 50, 66, 73, 76, 87]) (5) (1) )
  
      printf "TEST-1...%s\n" (driver ([68, 74, 16, 40, 6, -44, -36, 94, 6, -24, -4, -58, -16, 24]) (11) (9) )
  
      printf "TEST-2...%s\n" (driver ([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) (11) (9) )
  
      printf "TEST-3...%s\n" (driver ([91, 22]) (1) (0) )
  
      printf "TEST-4...%s\n" (driver ([-84, -80, -78, -76, -58, -54, -52, -48, -42, -42, -40, -38, -34, -32, -28, -24, -6, 2, 2, 4, 10, 14, 16, 18, 26, 26, 36, 40, 50, 52, 62, 64, 72, 74, 84, 90, 94, 96, 98]) (35) (28) )
  
      printf "TEST-5...%s\n" (driver ([1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1]) (13) (10) )
  
      printf "TEST-6...%s\n" (driver ([10, 19, 25, 29, 32, 37, 40, 43, 43, 44, 46, 51, 51, 54, 56, 58, 63, 79, 83, 86, 87, 97, 97]) (11) (2) )
  
      printf "TEST-7...%s\n" (driver ([-48, -28, 10, 30, 78, -72, 78, 52, -52, -68, 56, 42, 8, -42, 16, -56, 2, -90, -26, -28, -56, -2, 80, -50, 98, -64, -96, 10, -10, 44, 98, -48, -88, 42, 30, 24, 38, -26, -52, -12, 0, 34, -82, -80, 0, -84, -20]) (25) (23) )
  
      printf "TEST-8...%s\n" (driver ([0, 0, 1, 1, 1, 1, 1, 1]) (6) (2) )
  
      printf "TEST-9...%s\n" (driver ([25, 82]) (1) (0) )
  
source_py: def remove_minimum_elements_either_side_2min_max(arr, n):
      longest_start = (- 1)
      longest_end = 0
      for start in range(n):
          min = sys.maxsize
          max = (- sys.maxsize)
          for end in range(start, n):
              val = arr[end]
              if (val < min):
                  min = val
              if (val > max):
                  max = val
              if ((2 * min) <= max):
                  break
              if (((end - start) > (longest_end - longest_start)) or (longest_start == (- 1))):
                  longest_start = start
                  longest_end = end
      if (longest_start == (- 1)):
          return n
      return (n - ((longest_end - longest_start) + 1))
source_cpp: int remove_minimum_elements_either_side_2min_max(vector<int> arr, int n) {
    int longest_start = - 1, longest_end = 0;
    for ( int start = 0;
    start < n;
    start ++ ) {
      int min = INT_MAX, max = INT_MIN;
      for ( int end = start;
      end < n;
      end ++ ) {
        int val = arr [ end ];
        if ( val < min ) min = val;
        if ( val > max ) max = val;
        if ( 2 * min <= max ) break;
        if ( end - start > longest_end - longest_start || longest_start == - 1 ) {
          longest_start = start;
          longest_end = end;
        }
      }
    }
    if ( longest_start == - 1 ) return n;
    return ( n - ( longest_end - longest_start + 1 ) );
  }