values of non-negative integers. Pick any subset of its elements (empty or the whole array included) and add up the chosen numbers. Do this for every possible subset.
Return the bitwise OR (|) of all the sums you get.
There are far too many subsets to try them all, so look for a pattern.values=[4, 1, 2] → 7
Picking any subset gives the sums 0, 1, 2, …, 7. Their bitwise OR is 7.
values=[8, 8] → 24
The possible sums are 0, 8 and 16. 8 | 16 = 24.
values=[0] → 0
Every sum is zero.
values=[4, 1, 2]
7
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.