Bitwise ORs of Subarrays

Medium · Bit Manipulation · about 25 minutes

Asked at Google, Amazon, Meta.

Return the number of distinct values among the bitwise ORs of all non-empty contiguous subarrays of arr.