2401. Longest Nice Subarray
On This Page
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