Space efficient C # program to count all substrings with same first and last characters .
using System ; public class GFG { static int countSubstringWithEqualEnds ( string s ) { int result = 0 ; int n = s . Length ;