Given an array of strings, return the maximum single number when merging all the elements in the array.
For example [3, 30, 34, 5, 9] then we return 9534330.
The Analysis
This problem sounds complex but if we note some tricks below, then it become a solvable problem.
We always want to have the highest digit comes first if it is possible. In order to achieve this goal, we treat the given array as string, and then sort these strings in lexicographically descending order as mentioned next.
For given two strings X and Y, we merge as XY if X > Y in lexicographically order, YX otherwise.