Party Over: Sorting Strings Problem
Help Ninja sort the provided list of strings according to a specific condition given by a monster. The condition is to sort the strings based on the last letter. If two strings have the same last letter, sort them using the second last letter, and so on.
Input:
The input starts with an integer 'T', which represents the number of test cases.
Each test case begins with an integer 'n', the number of strings.
Followed by a line of 'n' space-separated strings to be sorted.
Output:
For every test case, output the strings sorted according to the last character, on a new line.
Example:
Input:
T = 1
n = 3
strings = ['abc', 'xyz', 'def']
Output:
['abc', 'def', 'xyz']
Constraints:
- 1 <= T <= 10
- 1 <= n <= 103
- 1 <= length of each string <= 102
Note:
You only need to implement the function that handles the sorting. Output is already managed.
Be the first one to answer
Add answer anonymously...
Top WatchGuard Technologies Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
>
WatchGuard Technologies Software Developer Intern Interview Questions
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