title: Maximum Number Characters Two Character String
signature: function maximumNumberCharactersTwoCharacterString($str) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($str, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($str), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      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));
      
  }
  
  main();
  ?>
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;
  }