As reported: Rubrik SDE-1 (2026 graduates, 2026), one coding problem.
There are N storage nodes with values A[0..N−1], where 0 ≤ A[i] < 2^K. You may perform any number of operations, in any order:
- Prefix compression: choose an index
iand aK-bit maskx; setA[j] = A[j] & xfor everyj ≤ i. - Suffix expansion: choose an index
iand aK-bit maskx; setA[j] = A[j] | xfor everyj ≥ i.
Count the number of distinct arrays that can be reached (the starting array included), modulo 998244353. Two arrays differ if they differ at some position.
Example 1
A = [1,0], K = 1 -> 4
All four arrays [0,0], [0,1], [1,0], [1,1] are reachable: [1,0] itself; AND the prefix up to index 0 with 0 → [0,0]; OR the suffix from index 1 with 1 → [1,1]; both → [0,1].
Example 2
A = [2,1,3], K = 2 -> 20
Constraints: 1 ≤ N ≤ 2·10^5; 1 ≤ K ≤ 30; 0 ≤ A[i] < 2^K.
Code runner format: two lines — A as a JSON array and K. Implement countReachable(a, k); the harness prints the count modulo 998244353.