commit c885e6210b65a98bbc0ab30deb6b525e4481a990
parent 0ecc1c85ecedb78b2c64848648e1f255dd338d7d
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Sat, 14 Sep 2024 15:04:36 +0200
1 Random Problem
Diffstat:
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/Problems/1839.cpp b/Problems/1839.cpp
@@ -0,0 +1,23 @@
+class Solution {
+ public:
+ int longestBeautifulSubstring(const string &word) const {
+ static const char *order = "aeiou";
+ int i = 0, j = 0, cnt = 0;
+ int res = 0;
+
+ while (i < size(word)) {
+ if (word[i] == order[j]) {
+ while (word[i] == order[j])
+ i++, cnt++;
+ if (++j == 5) res = max(res, cnt);
+ } else {
+ while (i < size(word) && word[i] != 'a')
+ i++;
+ cnt = 0;
+ j = 0;
+ }
+ }
+
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -1011,6 +1011,7 @@ for solving problems.
| 1833 | Medium | [Maximum Ice Cream Bars](Problems/1833.cpp) |
| 1834 | Medium | [Single-Threaded CPU](Problems/1834.cpp) |
| 1838 | Medium | [Frequency of the Most Frequent Element](Problems/1838.cpp) |
+| 1839 | Medium | [Longest Substring Of All Vowels in Order](Problems/1839.cpp) |
| 1845 | Medium | [Seat Reservation Manager](Problems/1845.cpp) |
| 1846 | Medium | [Maximum Element After Decreasing and Rearranging](Problems/1846.cpp) |
| 1850 | Medium | [Minimum Adjacent Swaps to Reach the Kth Smallest Number](Problems/1850.cpp) |