3309. Maximum Possible Number by Binary Concatenation Medium

@problem@discussion
#Array#Bit Manipulation#Enumeration



1/**
2 * [3309] Maximum Possible Number by Binary Concatenation
3 *
4 * You are given an array of integers nums of size 3.
5 * Return the maximum possible number whose binary representation can be formed by concatenating the binary representation of all elements in nums in some order.
6 * Note that the binary representation of any number does not contain leading zeros.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">nums = [1,2,3]</span>
11 * Output: 30
12 * Explanation:
13 * Concatenate the numbers in the order [3, 1, 2] to get the result "11110", which is the binary representation of 30.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">nums = [2,8,16]</span>
18 * Output: 1296
19 * Explanation:
20 * Concatenate the numbers in the order [2, 8, 16] to get the result "10100010000", which is the binary representation of 1296.
21 * </div>
22 *  
23 * Constraints:
24 * 
25 * 	nums.length == 3
26 * 	1 <= nums[i] <= 127
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/maximum-possible-number-by-binary-concatenation/
32// discuss: https://leetcode.com/problems/maximum-possible-number-by-binary-concatenation/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn max_good_number(nums: Vec<i32>) -> i32 {
38        0
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_3309() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.