commit 0ecc1c85ecedb78b2c64848648e1f255dd338d7d
parent ca5b3868b4b0e22d430c9eb49399f48f29cc486e
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Fri, 13 Sep 2024 17:59:20 +0200
1 Random Problem
Diffstat:
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/Problems/2419.cpp b/Problems/2419.cpp
@@ -0,0 +1,18 @@
+class Solution {
+ public:
+ int longestSubarray(const vector<int> &nums) const {
+ const int maxi = *max_element(begin(nums), end(nums));
+
+ int res = 0, cnt = 0;
+ for (const int n : nums) {
+ if (n == maxi)
+ cnt++;
+ else {
+ res = max(res, cnt);
+ cnt = 0;
+ }
+ }
+
+ return max(res, cnt);
+ }
+};
diff --git a/README.md b/README.md
@@ -1195,6 +1195,7 @@ for solving problems.
| 2414 | Medium | [Length of the Longest Alphabetical Continuous Substring](Problems/2414.cpp) |
| 2415 | Medium | [Reverse Odd Levels of Binary Tree](Problems/2415.cpp) |
| 2418 | Easy | [Sort the People](Problems/2418.cpp) |
+| 2419 | Medium | [Longest Subarray With Maximum Bitwise AND](Problems/2419.cpp) |
| 2421 | Medium | [Number of Good Paths](Problems/2421.cpp) |
| 2423 | Easy | [Remove Letter To Equalize Frequency](Problems/2423.cpp) |
| 2424 | Medium | [Longest Uploaded Prefix](Problems/2424.cpp) |