title: Maximum Number Characters Two Character String
signature: fun maximumNumberCharactersTwoCharacterString(str: String): Int {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(str: String, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(str), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver("cI", -1)
      println("TEST-0...${result}")
      
      result = driver("76478", 2)
      println("TEST-1...${result}")
      
      result = driver("1", -1)
      println("TEST-2...${result}")
      
      result = driver("tr", -1)
      println("TEST-3...${result}")
      
      result = driver("10", -1)
      println("TEST-4...${result}")
      
      result = driver("01", -1)
      println("TEST-5...${result}")
      
      result = driver("Rmhzp", -1)
      println("TEST-6...${result}")
      
      result = driver("5784080133917", 10)
      println("TEST-7...${result}")
      
      result = driver("1100", 0)
      println("TEST-8...${result}")
      
      result = driver("OK", -1)
      println("TEST-9...${result}")
      
          
  }
  
  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;
  }