Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Let <code>dp[i]</code> be the set of all the bitwise <code>OR</code> of all the subarrays ending at index <code>i</code>.
We start from <code>nums[i]</code>, taking the bitwise <code>OR</code> result by including elements one by one from <code>i</code> towards left. Notice that only unset bits can become set on adding an element, and set bits never become unset again.
Hence <code>dp[i]</code> can contain at most 30 elements.