Form the Biggest Number
Given an array “A” of positive integers. Your task is to make the largest number possible formed by concatenating each of the array elements exactly once.
Example:
Let's say the given array is [ 9, 98, 7].
All the possible numbers formed by concatenating each of the array elements are 7989,7998,9879,9897,9987,9798. Among the six numbers, 9987 is the greatest number. Hence the answer is 9987.
Input format:
The first line of input contains an integer ‘T’ denoting the number of test cases.
Then the T test cases follow.
The first line of each test case contains an integer 'N' denoting the number of elements in the array.
The second line of each test case contains 'N' space-separated integers denoting the array elements.
Output format:
For each test case, print the largest number possible formed by concatenating each of the array elements exactly once.
Note:
You do not need to print anything. It has already been taken care of. Just implement the given function.
Constraints:
1<= T <=10
1<= N <=10^3
0<= A[i] <=10^9
Time Limit: 1sec
Be the first one to answer
Add answer anonymously...
Top Tata 1mg Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app