You are given a 0-indexed array of positive integers nums. Group it into disjoint consecutive pairs: (nums[0], nums[1]), (nums[2], nums[3]), and so on.
For each pair, concatenate the decimal representation of the second element onto the first to form a single number (e.g. 12 and 21 form 1221). If the array length is odd, the final element forms a number by itself.
Return the smallest of the resulting numbers.
Examples
Example 1
Input: nums = [15,24,34,10,12,21,45,67]
Output: 1221
Explanation: The pairs form 1524, 3410, 1221, and 4567. The smallest is 1221. Note that (34, 10) forms 3410: the full digits of the second element are appended.
Example 2
Input: nums = [34,10,7]
Output: 7
Explanation: The pair (34, 10) forms 3410, and the final element 7 stands alone. The smallest is 7.
Example 3
Input: nums = [34,10,3,40]
Output: 340
Explanation: The pairs form 3410 and 340. The smallest is 340.
Constraints
1≤nums.length≤105
1≤nums[i]≤104
Loading editor...
Log in to run your code. Your draft is saved in this browser.Log inSign up