title: Maximum Number Characters Two Character String
signature: class Solution {
  
      public Integer maximumNumberCharactersTwoCharacterString(String str) {
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;
  }
question_info.extension: java
question_info.entry_fn_name: maximumNumberCharactersTwoCharacterString
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": -1, "inputs": {"str": "cI"}}, {"idx": 1, "outputs": 2, "inputs": {"str": "76478"}}, {"idx": 2, "outputs": -1, "inputs": {"str": "1"}}, {"idx": 3, "outputs": -1, "inputs": {"str": "tr"}}, {"idx": 4, "outputs": -1, "inputs": {"str": "10"}}, {"idx": 5, "outputs": -1, "inputs": {"str": "01"}}, {"idx": 6, "outputs": -1, "inputs": {"str": "Rmhzp"}}, {"idx": 7, "outputs": 10, "inputs": {"str": "5784080133917"}}, {"idx": 8, "outputs": 0, "inputs": {"str": "1100"}}, {"idx": 9, "outputs": -1, "inputs": {"str": "OK"}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(String str, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(str,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution("cI", -1);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution("76478", 2);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution("1", -1);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution("tr", -1);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution("10", -1);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution("01", -1);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution("Rmhzp", -1);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution("5784080133917", 10);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution("1100", 0);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution("OK", -1);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(String str, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(str),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__