C# Clear Solution with Explanation
My way to come up with the formula:\n\nWord: abcdef\n\nPossible substrings:\na ab abc abcd abcde abcdef\nb bc bcd bcde bcdef\nc cd cde cdef\nd de def\ne ef\nf\n
**My way to come up with the formula:**\n```\nWord: abcdef\n\nPossible substrings:\na ab abc abcd abcde abcdef\nb bc bcd bcde bcdef\nc cd cde cdef\nd de def\ne ef\nf\n\nWordLength = 6\nword[0] a: 6 (6 substrings in a first row)\nword[1] b: 5 + 5 (5 substrings in a first row and 5 substrings in a second row)\nword[2] c: 4 + 4 + 4 \nword[3] d: 3 + 3 + 3 + 3\nword[4] e: 2 + 2 + 2 + 2 + 2\nword[5] f: 1 + 1 + 1 + 1 + 1 + 1\n...\nword[i] : (WordLength - i) * (i+1) // count of elements in a row * count of groups\n```\n\n**Solution:**\n```\n\tprivate readonly char[] Vowels = new char[] {\'a\', \'e\', \'i\', \'o\', \'u\'};\n    \n\tpublic long CountVowels2(string word) {\n        long result = 0;\n        long wordLength = word.Length;\n        for (int i=0; i<wordLength; i++) {\n            if (Vowels.Contains(word[i])) \n                result += (wordLength - i) * (i+1);\n        }\n        return result;\n    }\n```
[]