Skip to content

Commit d490a53

Browse files
authored
Create 2419. Longest Subarray With Maximum Bitwise A1ND1
1 parent acb81fd commit d490a53

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int longestSubarray(vector<int>& nums) {
4+
int maxi = *max_element(nums.begin(), nums.end());
5+
int ans = 0;
6+
int size = 0;
7+
for (auto it : nums) {
8+
if (it == maxi)
9+
ans = max(ans, ++size);
10+
else
11+
size = 0;
12+
}
13+
return ans;
14+
}
15+
};

0 commit comments

Comments
 (0)