Dcoder icon

The Homework @ Dcoder

By Lochard | As a newbie programmer | 15 Apr 2023


Problem: As the students were not focusing much on the lecture. The professor became very angry and decided to give a homework to all the students.

So some of the students started trying to convince the professor not to do so. So the professor gives them a K digits and asks the students to make the largest number possible from these digits. If they able to do it, they don't need to do the homework. So you being the smartest student decided to solve the problem.

Input: The first line of input consists of single integer T denoting the number of test cases.

The first line of each test case has a single integer K.

The second line of each test case consists of K space separated integers denoting K digits.

Output: Print the largest number possible using these digits.

Constraints: 1<=T<=100.

1<=K<=100.

0<=Digits<=9.

Sample Input: 1

5

1 4 5 9 2

Sample Output: 

95421

for i in range(int(input())):
  input()
  n = sorted(input().split(), reverse=True)
  print(''.join(n))

How do you rate this article?

0


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.