leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit ab390eb45334ea1a668699475116fd0e744b1a92
parent 51904d519bbf95ed965c3c6052e9a94eda24db6b
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 12 Feb 2024 20:10:10 +0000

1 Random Problem

Diffstat:
AProblems/2063.cpp | 14++++++++++++++
MREADME.md | 1+
2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/Problems/2063.cpp b/Problems/2063.cpp @@ -0,0 +1,14 @@ +class Solution { + inline static bool isVowel(const char c) { + return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'; + } + + public: + long long countVowels(const string &word) const { + long long n = size(word), res = 0; + for (int i = 0; i < n; i++) { + if (isVowel(word[i])) res += (i + 1) * (n - i); + } + return res; + } +}; diff --git a/README.md b/README.md @@ -960,6 +960,7 @@ for solving problems. | 2044 | Medium | [Count Number of Maximum Bitwise-OR Subsets](Problems/2044.cpp) | | 2050 | Hard | [Parallel Courses III](Problems/2050.cpp) | | 2058 | Medium | [Find the Minimum and Maximum Number of Nodes Between Critical Points](Problems/2058.cpp) | +| 2063 | Medium | [Vowels of All Substrings](Problems/2063.cpp) | | 2073 | Easy | [Time Needed to Buy Tickets](Problems/2073.cpp) | | 2074 | Medium | [Reverse Nodes in Even Length Groups](Problems/2074.cpp) | | 2079 | Medium | [Watering Plants](Problems/2079.cpp) |