title: Maximum Number Characters Two Character String
signature: pub fn maximum_number_characters_two_character_string(str: String) -> i32 {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: i32, expected: i32)->bool{
  return actual==expected
  }
  pub fn driver(str: String, expected: i32)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(str), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        "cI".to_string(), 
        -1
      ));
      
      println!("TEST-1...{}", driver(
        "76478".to_string(), 
        2
      ));
      
      println!("TEST-2...{}", driver(
        "1".to_string(), 
        -1
      ));
      
      println!("TEST-3...{}", driver(
        "tr".to_string(), 
        -1
      ));
      
      println!("TEST-4...{}", driver(
        "10".to_string(), 
        -1
      ));
      
      println!("TEST-5...{}", driver(
        "01".to_string(), 
        -1
      ));
      
      println!("TEST-6...{}", driver(
        "Rmhzp".to_string(), 
        -1
      ));
      
      println!("TEST-7...{}", driver(
        "5784080133917".to_string(), 
        10
      ));
      
      println!("TEST-8...{}", driver(
        "1100".to_string(), 
        0
      ));
      
      println!("TEST-9...{}", driver(
        "OK".to_string(), 
        -1
      ));
      
  }
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;
  }