Tap here to switch tabs
Problem
Submissions

Problem: Longest Nice Subarray

med
30 min
Try to solve the Longest Nice Subarray problem.

Statement

Given an integer array nums, a subarray is called nice if for every pair of distinct indices i and j within that subarray, the bitwise AND of the two values is equal to 00, meaning nums[i] & nums[j] == 0.

Return the maximum possible length of a nice subarray of nums.

Note: A subarray is a contiguous segment of nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Nice Subarray

med
30 min
Try to solve the Longest Nice Subarray problem.

Statement

Given an integer array nums, a subarray is called nice if for every pair of distinct indices i and j within that subarray, the bitwise AND of the two values is equal to 00, meaning nums[i] & nums[j] == 0.

Return the maximum possible length of a nice subarray of nums.

Note: A subarray is a contiguous segment of nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9