title: Count Substrings With Same First And Last Characters
signature: class Solution {
  
      public Integer countSubstringsWithSameFirstAndLastCharacters(String s) {
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;
  }
question_info.extension: java
question_info.entry_fn_name: countSubstringsWithSameFirstAndLastCharacters
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 5, "inputs": {"s": "LZIKA"}}, {"idx": 1, "outputs": 16, "inputs": {"s": "0556979952"}}, {"idx": 2, "outputs": 12, "inputs": {"s": "110010"}}, {"idx": 3, "outputs": 6, "inputs": {"s": "kGaYfd"}}, {"idx": 4, "outputs": 19, "inputs": {"s": "413567670657"}}, {"idx": 5, "outputs": 9, "inputs": {"s": "01001"}}, {"idx": 6, "outputs": 6, "inputs": {"s": "EQPuFa"}}, {"idx": 7, "outputs": 15, "inputs": {"s": "48848378"}}, {"idx": 8, "outputs": 4, "inputs": {"s": "110"}}, {"idx": 9, "outputs": 9, "inputs": {"s": "PLehNeP"}}]
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 s, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(s,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution("LZIKA", 5);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution("0556979952", 16);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution("110010", 12);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution("kGaYfd", 6);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution("413567670657", 19);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution("01001", 9);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution("EQPuFa", 6);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution("48848378", 15);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution("110", 4);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution("PLehNeP", 9);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(String s, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(s),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__