title: Count Substrings With Same First And Last Characters
signature: countSubstringsWithSameFirstAndLastCharacters(s) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(s, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(s), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          "LZIKA", 
          5)
      }");
  
      print("TEST-1...${driver(
          "0556979952", 
          16)
      }");
  
      print("TEST-2...${driver(
          "110010", 
          12)
      }");
  
      print("TEST-3...${driver(
          "kGaYfd", 
          6)
      }");
  
      print("TEST-4...${driver(
          "413567670657", 
          19)
      }");
  
      print("TEST-5...${driver(
          "01001", 
          9)
      }");
  
      print("TEST-6...${driver(
          "EQPuFa", 
          6)
      }");
  
      print("TEST-7...${driver(
          "48848378", 
          15)
      }");
  
      print("TEST-8...${driver(
          "110", 
          4)
      }");
  
      print("TEST-9...${driver(
          "PLehNeP", 
          9)
      }");
  
      return 0;
  }
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;
  }