Title Description
Enter a positive integer array, the array of all the numbers arranged in a number spliced together, the splice can print out all numbers smallest one. 3,32,321 input array} {e.g., print the minimum number of three numbers can be arranged to 321,323.
Thinking
Data within the vector container sorted according After a and b into string
if a + b <b + aa row rules preceding sorting,
such as 221 because 212 <221 it is sorted to 21 is 2
the to_string () may be int into a string
js code
function PrintMinNumber(numbers)
{
// write code here
let res = ''
numbers.sort((a,b) => {
let A = ''
let B = ''
A += String(a)
A += String(b)
B += String(b)
B += String(a)
return A - B
})
for (let i of numbers) res += i
return res
}