3133. Minimum Array End Medium

@problem@discussion
#Bit Manipulation



1/**
2 * [3133] Minimum Array End
3 *
4 * You are given two integers n and x. You have to construct an array of positive integers nums of size n where for every 0 <= i < n - 1, nums[i + 1] is greater than nums[i], and the result of the bitwise AND operation between all elements of nums is x.
5 * Return the minimum possible value of nums[n - 1].
6 *  
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">n = 3, x = 4</span>
10 * Output: <span class="example-io">6</span>
11 * Explanation:
12 * nums can be [4,5,6] and its last element is 6.
13 * </div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">n = 2, x = 7</span>
17 * Output: <span class="example-io">15</span>
18 * Explanation:
19 * nums can be [7,15] and its last element is 15.
20 * </div>
21 *  
22 * Constraints:
23 * 
24 * 	1 <= n, x <= 10^8
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/minimum-array-end/
30// discuss: https://leetcode.com/problems/minimum-array-end/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn min_end(n: i32, x: i32) -> i64 {
36        
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_3133() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.