Problem of the day
You are given ‘str’ = ‘A1 person3 good2’, in this we can see the ordering of the words like ‘A’, ‘good’ ‘person’ according to the suffix number. Hence the answer string is ‘A good person’.
The first line of input contains a single integer ‘T’, representing the number of test cases.
The first line of each test case contains a string ‘str’ representing the given string.
For each test case, print a single string representing the sorted string.
Print a separate line for each test case.
1 <= T <= 10
1 <= |str| <= 10^6
‘str’ will contain upper and lower case characters of the English alphabet.
‘str’ will not contain more than 9 words.
Time Limit: 1 sec.
You do not need to print anything. It has already been taken care of. Just implement the given function.
2
A1 person3 good2
world2 hello1
A good person
hello world
For the first test case, ‘str’ = ‘A1 person3 good2’, in this we can see the ordering of the words like ‘A’, ‘good’ ‘person’ according to the suffix number. Hence the answer string is ‘A good person’.
For the second test case, ‘str’ = ‘world2 hello1’, in this we can see the ordering of the words like ‘ hello’, and ‘world’, according to the suffix number Hence the answer string is ‘hello world’.
2
Code1 studio2 coding3 ninjas4
hi1
Code studio coding ninjas
hi