Prefix OR
For an array $B$ containing $M$ non-negative integers, we define $f(B)$ to be the number of distinct values among its prefix bitwise ORs. Formally, let $P$ be an array of length $M$, such that: - $P_1 = B_1$ - $P_i = B_i \ \mid\ P_{i-1}$ for each $1 \lt i \leq M$. Here $\mid$ denotes the [bitwise OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR) operation. $f(B)$ is then defined to be th
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start