Consider an array of numeric strings where each string is a positive number with anywhere from 1 to 106 digits. Sort the array’s elements in non-decreasing, or ascending order of their integer values and print each element of the sorted array on a new line.
Function Description
Complete the bigSorting function in the editor below. It should return the sorted string array.
bigSorting has the following parameter(s):
- unsorted: an unsorted array of integers as strings
Input Format
The first line contains an integer, n, denoting the number of strings in unsorted. Each of the n subsequent lines contains an integer string unsorted[i].
Constraints
- 1 <= n <= 2 X 105
- Each string is guaranteed to represent a positive integer without leading zeros.
- The total number of digits across all strings in unsorted is between 1 and 106 (inclusive).
Output Format
Print each element of the sorted array on a new line.
Sample Input 0
1 | 6 |
Sample Output 0
1 | 1 |
Explanation 0
The initial array of strings is unsorted = [31415926535897932384626433832795,1,3,10,3,5].
When we order each string by the real-world integer value it represents, we get:
We then print each value on a new line, from smallest to largest.
Sample Input 1
1 | 8 |
Sample Output 1
1 | 1 |
Solution
1 | // Complete the bigSorting function below. |