title: Maximum Number Characters Two Character String
signature: maximumNumberCharactersTwoCharacterString(str) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(str, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(str), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          "cI", 
          -1)
      }");
  
      print("TEST-1...${driver(
          "76478", 
          2)
      }");
  
      print("TEST-2...${driver(
          "1", 
          -1)
      }");
  
      print("TEST-3...${driver(
          "tr", 
          -1)
      }");
  
      print("TEST-4...${driver(
          "10", 
          -1)
      }");
  
      print("TEST-5...${driver(
          "01", 
          -1)
      }");
  
      print("TEST-6...${driver(
          "Rmhzp", 
          -1)
      }");
  
      print("TEST-7...${driver(
          "5784080133917", 
          10)
      }");
  
      print("TEST-8...${driver(
          "1100", 
          0)
      }");
  
      print("TEST-9...${driver(
          "OK", 
          -1)
      }");
  
      return 0;
  }
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;
  }