Solving Bitwise ORs of Subarrays in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

Example 1:

Input: [0]
Output: 1
Explanation: 
There is only one possible result: 0.

Example 2:

Input: [1,1,2]
Output: 3
Explanation: 
The possible subarrays are [1], [1], [2], [1, 1], [1, 2], [1, 1, 2].
These yield the results 1, 1, 2, 1, 3, 3.
There are 3 unique values, so the answer is 3.

Example 3:

Input: [1,2,4]
Output: 6
Explanation: 
The possible results are 1, 2, 3, 4, 6, and 7.

Note:

  1. 1 <= A.length <= 50000
  2. 0 <= A[i] <= 10^9
    [001]  
    [001 011] [011]  
    [001 011 100] [011 100] [100]  
    [001 011 100 110] [011 100 110] [100 110] [110]  
    [001 011 100 110 101] [011 100 110 101] [100 110 101] [110 101] [101]  
    001  
    011 011  
    111 111 100  
    111 111 110 110  
    111 111 111 111 101  
    001  
    011  
    111 100  
    111 110  
    111 101  

See the full details of the problem Bitwise ORs of Subarrays at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go