Beginners:Chang and Bitwise Or

i m not able to understand the problem .plz can someone explain this to me with some example??

As the problem reads there are n number and in each step you select a set of number and remove them . If you remove them the cost incurred while doing so will will be the bitwise OR of set of numbers. Your jobs is to minimize the cost.

Hint : Think of the following what happens if you take OR of 2 numbers and what is result if you add two numbers .What would be minimal of the two

Hi @navya798 !

In the problem, for each test case, one is given a set of numbers. “Cost” for “an” operation is defined to be bitwise OR of the elements in the sequence. So, basically we have been provided a sequence of numbers. We can remove elements from the list (any number of elements at a time) and the cost of the operation shall be as defined above. We have to remove all elements from the list such that we get the least total cost as per the above definition of “cost”.

To get an idea of how to approach, think of how OR works. Then think if you really need to work on an approach of a set of elements that shall provide minimum cost ? Align your thinking by calculation Bitwise OR of a sequence of elements in different orders and see what your answer is.

So, basically, for each test case, find the “minimum” cost !!!

I hope this helps. :slight_smile: