title: Count Substrings With Same First And Last Characters
signature: pub fn count_substrings_with_same_first_and_last_characters(s: 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(s: String, expected: i32)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(s), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        "LZIKA".to_string(), 
        5
      ));
      
      println!("TEST-1...{}", driver(
        "0556979952".to_string(), 
        16
      ));
      
      println!("TEST-2...{}", driver(
        "110010".to_string(), 
        12
      ));
      
      println!("TEST-3...{}", driver(
        "kGaYfd".to_string(), 
        6
      ));
      
      println!("TEST-4...{}", driver(
        "413567670657".to_string(), 
        19
      ));
      
      println!("TEST-5...{}", driver(
        "01001".to_string(), 
        9
      ));
      
      println!("TEST-6...{}", driver(
        "EQPuFa".to_string(), 
        6
      ));
      
      println!("TEST-7...{}", driver(
        "48848378".to_string(), 
        15
      ));
      
      println!("TEST-8...{}", driver(
        "110".to_string(), 
        4
      ));
      
      println!("TEST-9...{}", driver(
        "PLehNeP".to_string(), 
        9
      ));
      
  }
source_py: def count_substrings_with_same_first_and_last_characters(s):
      result = 0
      n = len(s)
      for i in range(n):
          for j in range(i, n):
              if (s[i] == s[j]):
                  result = (result + 1)
      return result
source_cpp: int count_substrings_with_same_first_and_last_characters(string s) {
    int result = 0;
    int n = s . length ( );
    for ( int i = 0;
    i < n;
    i ++ ) for ( int j = i;
    j < n;
    j ++ ) if ( s [ i ] == s [ j ] ) result ++;
    return result;
  }