Пример:
Код: Выделить всё
arr= [4,2,4,1], n = 4
Код: Выделить всё
[1,2,4,6]
Код: Выделить всё
All possible distinct increasing subsequences are:
[4]
[2]
[2, 4]
[1]
Bit wise or values are:
[4]
[2]
[2 | 4] = [6]
[1]
So values are [2,4,6, 1]
sorted result is [1,2,4,6]
Код: Выделить всё
arr = [3,2,4,6], n = 4
Код: Выделить всё
[2,3,4,6,7]
Код: Выделить всё
All increasing subsequences and corresponding bitwise or values are:
[3] : 3
[3, 4] : 7
[3, 4, 6] : 7
[3, 6] : 7
[2] : 2
[2, 4] : 6
[2, 4, 6] : 6
[2, 6] : 6
[4] : 4
[4, 6] : 6
[6] : 6
So distinct values are [3,7,2,6,4]
sorted result is [2,3,4,6,7]
Код: Выделить всё
1
Подробнее здесь: [url]https://stackoverflow.com/questions/78722724/find-unique-or-combination-for-given-array[/url]