2568. Minimum Impossible OR

Medium

238

12

You are given a **0-indexed** integer array `nums`

.

We say that an integer x is **expressible** from `nums`

if there exist some integers `0 <= index`

for which _{1} < index_{2} < ... < index_{k} < nums.length`nums[index`

. In other words, an integer is expressible if it can be written as the bitwise OR of some subsequence of _{1}] | nums[index_{2}] | ... | nums[index_{k}] = x`nums`

.

Return *the minimum positive non-zero integer that is not *

`nums`

.

**Example 1:**

Input:nums = [2,1]Output:4Explanation:1 and 2 are already present in the array. We know that 3 is expressible, since nums[0] | nums[1] = 2 | 1 = 3. Since 4 is not expressible, we return 4.

**Example 2:**

Input:nums = [5,3,2]Output:1Explanation:We can show that 1 is the smallest number that is not expressible.

**Constraints:**

`1 <= nums.length <= 10`

^{5}`1 <= nums[i] <= 10`

^{9}

Accepted

11K

Submissions

19.2K

Acceptance Rate

57.5%

Seen this question in a real interview before?

1/4

Yes

No

Discussion (0)

Related Topics

Copyright ©️ 2023 LeetCode All rights reserved