2568. Minimum Impossible OR Medium

@problem@discussion
#Array#Bit Manipulation#Brainteaser



1/**
2 * [2568] Minimum Impossible OR
3 *
4 * You are given a 0-indexed integer array nums.
5 * We say that an integer x is expressible from nums if there exist some integers 0 <= index1 < index2 < ... < indexk < nums.length for which nums[index1] | nums[index2] | ... | nums[indexk] = x. In other words, an integer is expressible if it can be written as the bitwise OR of some subsequence of nums.
6 * Return the minimum positive non-zero integer that is not expressible from nums.
7 *  
8 * <strong class="example">Example 1:
9 * 
10 * Input: nums = [2,1]
11 * Output: 4
12 * Explanation: 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.
13 * 
14 * <strong class="example">Example 2:
15 * 
16 * Input: nums = [5,3,2]
17 * Output: 1
18 * Explanation: We can show that 1 is the smallest number that is not expressible.
19 * 
20 *  
21 * Constraints:
22 * 
23 * 	1 <= nums.length <= 10^5
24 * 	1 <= nums[i] <= 10^9
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/minimum-impossible-or/
30// discuss: https://leetcode.com/problems/minimum-impossible-or/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn min_impossible_or(nums: Vec<i32>) -> i32 {
36        0
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_2568() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.