title: Maximum Number Characters Two Character String
signature: function maximum_number_characters_two_character_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.entry_fn_name: maximum_number_characters_two_character_string
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(str, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(str) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver("cI", -1)
      print(string.format("TEST-0...%s",result))
  
      result = driver("76478", 2)
      print(string.format("TEST-1...%s",result))
  
      result = driver("1", -1)
      print(string.format("TEST-2...%s",result))
  
      result = driver("tr", -1)
      print(string.format("TEST-3...%s",result))
  
      result = driver("10", -1)
      print(string.format("TEST-4...%s",result))
  
      result = driver("01", -1)
      print(string.format("TEST-5...%s",result))
  
      result = driver("Rmhzp", -1)
      print(string.format("TEST-6...%s",result))
  
      result = driver("5784080133917", 10)
      print(string.format("TEST-7...%s",result))
  
      result = driver("1100", 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver("OK", -1)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
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"}}]