Skip to content

Commit 1a6e3d3

Browse files
committed
Jul 30
1 parent f97c52e commit 1a6e3d3

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution:
2+
def longestSubarray(self, nums: list[int]) -> int:
3+
max_num = max(nums)
4+
curr_length, max_length = 0, 1
5+
for num in nums:
6+
if num == max_num:
7+
curr_length += 1
8+
else:
9+
curr_length = 0
10+
max_length = max(max_length, curr_length)
11+
return max_length
12+
13+
14+
def main():
15+
nums = [1, 2, 3, 3, 2, 2]
16+
assert Solution().longestSubarray(nums) == 2
17+
18+
nums = [1, 2, 3, 4]
19+
assert Solution().longestSubarray(nums) == 1
20+
21+
22+
if __name__ == '__main__':
23+
main()

2025-07-July-LeetCoding-Challenge/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
| July 26 | [3480. Maximize Subarrays After Removing One Conflicting Pair](https://leetcode.com/problems/maximize-subarrays-after-removing-one-conflicting-pair/) | Hard | Unsolved |
3333
| July 27 | [2210. Count Hills and Valleys in an Array](https://leetcode.com/problems/count-hills-and-valleys-in-an-array/) | Easy | Solved |
3434
| July 28 | [2044. Count Number of Maximum Bitwise-OR Subsets](https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets/) | Medium | Solved |
35-
| July 29 | []() | | |
36-
| July 30 | []() | | |
35+
| July 29 | [2411. Smallest Subarrays With Maximum Bitwise OR](https://leetcode.com/problems/smallest-subarrays-with-maximum-bitwise-or/) | Medium | Unsolved |
36+
| July 30 | [2419. Longest Subarray With Maximum Bitwise AND](https://leetcode.com/problems/longest-subarray-with-maximum-bitwise-and/) | Medium | Solved |
3737
| July 31 | []() | | |
3838

3939

4040
## Summary
4141
| Level | Problems | Solved | Unsolved |
4242
| --- | --- | --- | --- |
4343
| Easy | 7 | 7 | 0 |
44-
| Medium | 11 | 10 | 1 |
44+
| Medium | 13 | 11 | 2 |
4545
| Hard | 9 | 1 | 8 |

0 commit comments

Comments
 (0)