Search
⌘K

Leetcode 898. Bitwise ORs of Subarrays

Count how many distinct integers appear as the bitwise OR of any non-empty contiguous subarray of arr. Key insight: bitwise OR only accumulates bits so the number of distinct ORs ending at each position is bounded (≈bit-width of numbers), allowing an efficient iterative set-based accumulation for n up to 5·10^4 and values ≤ 10^9.

Asked at:

Microsoft

Microsoft


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late January, 2026

Microsoft

Microsoft

Senior

Same as the leetcode question, minus some flavor text

Comments

Your account is free and you can post anonymously if you choose.