title: Maximum Number Characters Two Character String
signature: function maximum_number_characters_two_character_string(str)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(str, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(str), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver("cI", -1);
      @printf("TEST-0...%s\n",result);
      
      result = driver("76478", 2);
      @printf("TEST-1...%s\n",result);
      
      result = driver("1", -1);
      @printf("TEST-2...%s\n",result);
      
      result = driver("tr", -1);
      @printf("TEST-3...%s\n",result);
      
      result = driver("10", -1);
      @printf("TEST-4...%s\n",result);
      
      result = driver("01", -1);
      @printf("TEST-5...%s\n",result);
      
      result = driver("Rmhzp", -1);
      @printf("TEST-6...%s\n",result);
      
      result = driver("5784080133917", 10);
      @printf("TEST-7...%s\n",result);
      
      result = driver("1100", 0);
      @printf("TEST-8...%s\n",result);
      
      result = driver("OK", -1);
      @printf("TEST-9...%s\n",result);
      
  end
  
  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;
  }