The score of a subsequence is the bitwise OR of all its elements (the empty subsequence has score 0). Given an integer array arr, find every distinct score achievable by a strictly increasing subsequence of arr, and return the values sorted in ascending order.
A subsequence keeps the index order of arr, and its values must be strictly increasing.
Input: arr = [3,2,4,6]
Output: [0,2,3,4,6,7]
Singletons give 2, 3, 4 and 6; [2,4] gives 2 | 4 = 6 and [3,4] gives 3 | 4 = 7. Longer chains such as [2,4,6] (OR 6) and [3,4,6] (OR 7) add no new values, and 0 comes from the empty subsequence.
Input: arr = [4,2,4,1]
Output: [0,1,2,4,6]
The second 4 can extend the earlier 2 (indices in order, values increasing), giving 6, but the trailing 1 extends nothing.
Input: arr = [1,2,4]
Output: [0,1,2,3,4,5,6,7]
Here a longer chain does matter: 7 is reachable only through the full subsequence [1,2,4].
1 <= arr.length <= 10^41 <= arr[i] <= 1024, so every score is below 2048