APT PORTFOLIO | OA | subset MEX
Anonymous User
1841

GIven an array integers. Find the smallest positive integer which cannot be formed by performing bitwise OR on all the elements of a chosen subset.
Note : bitwise OR value of an empty subset is 0

for eg :

arr = [2,3]

possible subsets
[]
[2]
[3]
[2,3]

possible Values of bitwise OR
[] ===>0
[2] ==>2
[3]===>3
[2,3]==>3

clearly the smallest positive integer that cannot be formed by doing bitwise OR of any subsets is "1".

Comments (5)