title: Maximum Number Characters Two Character String
signature: maximumNumberCharactersTwoCharacterString :: String -> Integer
  maximumNumberCharactersTwoCharacterString str = 
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 :: String -> Integer -> String
  driver str expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME str) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver ("cI") (-1) )
  
      printf "TEST-1...%s\n" (driver ("76478") (2) )
  
      printf "TEST-2...%s\n" (driver ("1") (-1) )
  
      printf "TEST-3...%s\n" (driver ("tr") (-1) )
  
      printf "TEST-4...%s\n" (driver ("10") (-1) )
  
      printf "TEST-5...%s\n" (driver ("01") (-1) )
  
      printf "TEST-6...%s\n" (driver ("Rmhzp") (-1) )
  
      printf "TEST-7...%s\n" (driver ("5784080133917") (10) )
  
      printf "TEST-8...%s\n" (driver ("1100") (0) )
  
      printf "TEST-9...%s\n" (driver ("OK") (-1) )
  
source_py: def maximum_number_characters_two_character_string(str):
      n = len(str)
      res = (- 1)
      for i in range(0, (n - 1)):
          for j in range((i + 1), n):
              if (str[i] == str[j]):
                  res = max(res, abs(((j - i) - 1)))
      return res
source_cpp: int maximum_number_characters_two_character_string(string & str) {
    int n = str . length ( );
    int res = - 1;
    for ( int i = 0;
    i < n - 1;
    i ++ ) for ( int j = i + 1;
    j < n;
    j ++ ) if ( str [ i ] == str [ j ] ) res = max ( res, abs ( j - i - 1 ) );
    return res;
  }