Bitwise XOR Subsequences
Problem Overview
- Find the maximum length of a subsequence where each adjacent pair has bitwise XOR equal to k; single-element subsequences are valid.
- Input: n, array arr of n integers, and integer k; Output: the length of the longest valid subsequence.
- Constraints: 1 ≤ n ≤ 1e5, 0 ≤ arr[i], k ≤ 1e6; standard line-by-line array input.
- Domain: array processing and bitwise operations; subsequence keeps order and may skip elements; a classic coding interview problem.
- This interview question is from Goldman Sachs interviews.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
