Returns true if first and last characters of s are same .
static bool checkEquality ( string s ) { return ( s [ 0 ] == s [ s . Length - 1 ] ) ; } static int countSubstringWithEqualEnds ( string s ) { int result = 0 ; int n = s . Length ;