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.

AnswerBot
4mo
Sort the list of strings based on the last character, then second last character, and so on.
Iterate through each string in the list
Sort the strings based on the last character first, then second last ...read more
Help your peers!
Add answer anonymously...
WatchGuard Technologies Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Party Over: Sorting Strings Problem Help Ninja sort the provided list of strings...read more
A Software Developer Intern was asked Q. Covid Vaccination Distribution Problem As the Government ramps up vaccination dr...read more
A Software Developer Intern was asked Q. Treasure Hunt Problem Statement Alex and Rome are engaged in a treasure hunt gam...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Party Over: Sorting Strings Problem Help Ninja sort the provided list of strings...read more
A Software Developer Intern was asked Q2. Covid Vaccination Distribution Problem As the Government ramps up vaccination dr...read more
A Software Developer Intern was asked Q3. Treasure Hunt Problem Statement Alex and Rome are engaged in a treasure hunt gam...read more
>
WatchGuard Technologies Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

