2419. Longest Subarray With Maximum Bitwise AND

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2419

class Solution:
    def longestSubarray(self, nums: List[int]) -> int:
        mx = max(nums)
        res = cnt = 0
        for v in nums:
            if v == mx:
                cnt += 1
                res = max(res, cnt)
            else:
                cnt = 0
        return res