Maximum Possible Number by Binary Concatenation - Problem
You are given an array of integers nums of size 3. Return the maximum possible number whose binary representation can be formed by concatenating the binary representation of all elements in nums in some order.
Note that the binary representation of any number does not contain leading zeros.
Input & Output
Example 1 — Basic Case
$
Input:
nums = [1,2,3]
›
Output:
30
💡 Note:
Binary representations: 1→"1", 2→"10", 3→"11". Optimal arrangement [1,3,2] gives "1"+"11"+"10"="11110" which equals 30 in decimal.
Example 2 — Larger Numbers
$
Input:
nums = [2,8,16]
›
Output:
2576
💡 Note:
Binary: 2→"10", 8→"1000", 16→"10000". Optimal order [2,8,16] gives "10"+"1000"+"10000"="101000010000" = 2576.
Example 3 — Single Digit Focus
$
Input:
nums = [5,6,7]
›
Output:
501
💡 Note:
Binary: 5→"101", 6→"110", 7→"111". Best arrangement [7,5,6] produces "111"+"101"+"110"="111101110" = 494.
Constraints
- nums.length == 3
- 1 ≤ nums[i] ≤ 107
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code