Problem
A subarray is nice if the bitwise AND of every pair of elements at different positions in it is 0. In other words, no bit is set in more than one of its elements. Given an array of positive integers nums, return the length of the longest nice subarray. A subarray of length 1 is always nice.
Example 1
- Input
- nums = [1, 3, 8, 48, 10]
- Output
- 3
- Why
- [3, 8, 48]
Example 2
- Input
- nums = [3, 1, 5, 11, 13]
- Output
- 1
Example 3
- Input
- nums = [1, 2, 4, 8, 16]
- Output
- 5
Constraints
1 <= nums.length <= 10^51 <= nums[i] <= 10^9