2401. Longest Nice Subarray

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

Содержание

LeetCode problem 2401

class Solution:
    def longestNiceSubarray(self, nums: List[int]) -> int:
        res = j = mask = 0
        for i, x in enumerate(nums):
            while mask & x:
                mask ^= nums[j]
                j += 1
            res = max(res, i - j + 1)
            mask |= x
        return res