Please solve the programming task below using a self-contained code snippet in a markdown code block.

You are given a 0-indexed string s consisting of only lowercase English letters. Return the number of substrings in s that begin and end with the same character.
A substring is a contiguous non-empty sequence of characters within a string.
 
Please complete the following python code precisely:
```python
class Solution:
    def numberOfSubstrings(self, s: str) -> int:
```