text and a letter letter. Count the non-empty substrings of text that both start and end with letter.
Substrings at different positions count separately, even if they read the same. A one-character substring equal to letter counts too.text='banana', letter='a' → 6
There are three a's. The three single "a"s qualify, plus "ana", "anana" and a second "ana": 6 in total.
text='kiwi', letter='p' → 0
There is no "p" in the string, so there are no such substrings.
text='ooo', letter='o' → 6
text='banana', letter='a'
6
Run checks the first 3 tests in your browser. Submit checks all 107 tests on the server, hidden ones included.