Free written solution

Longest Nice Subarray (LeetCode 2401): Solution and Explanation

Find the longest contiguous subarray in which every pair of elements has a bitwise AND of 0, meaning no two elements share a set bit.

Read the intuition, approach, code and complexity →