Блог пользователя ashishdtu007

Автор ashishdtu007, история, 21 месяц назад, По-английски

A subsequence is obtained by deleting some(possibly zero) elements of a sequence without changing the order of the elements in the sequence.

Given an array of n non-negative integers, find the smallest non-negative integer that can not be obtained as a bitwise OR of some subsequence of the given array. The bitwise OR of empty subsequence is 0.

example given arr = [1,3] output: 2

explanation:

[] -> bitwise OR is 0

[1] -> bitwise OR is 1

[1,3] -> bitwise OR is 3

[3] -> bitwise OR is 3

so 2 is the smallest non-negative integer that is not possible to form using the bitwise OR of a subsequence of the given array.

Constraints :

1 <= n <= 10^5

0 <= arr[i] <= 10^9

Please help in upsolving this problem. Any ideas, hints or solutions will be helpful.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится