Practice Longest Nice Subarray
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an array nums consisting of positive integers. We call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0. Return the length of the longest nice subarray. A subarray is a contiguous part of an array. Note that subarrays of length 1 are always considered nice.
Source: Longest Nice Subarray on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [1,3,8,48,10]
3
# Example 2
nums = [3,1,5,11,13]
1
Constraints
Related LeetCode Problems
Practice more problems similar to Longest Nice Subarray.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.